{"id":22562064,"url":"https://github.com/sanderhelleso/vendingmachine","last_synced_at":"2025-06-12T14:38:20.793Z","repository":{"id":96641550,"uuid":"153027045","full_name":"sanderhelleso/vendingMachine","owner":"sanderhelleso","description":"Project 1 for class CST238 Data Structrues - Vending Machine","archived":false,"fork":false,"pushed_at":"2018-10-14T23:17:37.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T12:45:03.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanderhelleso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-14T23:06:41.000Z","updated_at":"2019-05-09T06:44:49.000Z","dependencies_parsed_at":"2024-02-06T14:03:15.686Z","dependency_job_id":null,"html_url":"https://github.com/sanderhelleso/vendingMachine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sanderhelleso/vendingMachine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanderhelleso%2FvendingMachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanderhelleso%2FvendingMachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanderhelleso%2FvendingMachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanderhelleso%2FvendingMachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanderhelleso","download_url":"https://codeload.github.com/sanderhelleso/vendingMachine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanderhelleso%2FvendingMachine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259483525,"owners_count":22864985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T22:11:26.108Z","updated_at":"2025-06-12T14:38:20.771Z","avatar_url":"https://github.com/sanderhelleso.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project 1 for class CST238 Data Structrues - Vending Machine\n\u003cbr\u003e\n\n## Project Description\nIn this project, you should develop a program named project1.cpp which include a class called VendingMachine. Note that the class simulates an imaginary vending machine on the CSUMB campus. \nA user can buy a bottle of water ($1.50), a bottle of coffee ($2.00), a chip ($1.00), and a chocolate bar ($2.50) from the machine. The user can select several item(s) if the items are available from the machine. Furthermore, the user can de-select item(s) that are already selected. \nAfter finishing the selection of item(s), the user can pay for the items with either a debit card (Valid PIN: 7777) or cash. A user can try to pay the item(s) only one time and if the user fails to pay due to the incorrect PIN or insufficient cash amount, the machine will de-select all sections the user chose. \nNote that an administrator of the machine can refill the machine or reset it to the initial status.\nRead the following demo program and its sample run very carefully and identify data members and function members of the class to run the demo program.\n\n## Demo Program: The following code presents a demo program that uses the VendingMachine class.\n\n```\n1.\tint main()\n2.\t{\n3.\t    cout \u003c\u003c \"===== Welcome to CSUMB Vending Machine =====\\n\";\n4.\t\n5.\t    VendingMachine machine1;\n6.\t    cout \u003c\u003c machine1.display();  // Display the ID and name of machine1.\n7.\t\n8.\t    VendingMachine machine2 (200, \"Library\"); \n9.\t    cout \u003c\u003c machine2.display();\n10.\t\n11.\t    cout \u003c\u003c \"\\n===== Updated machine1 Info =====\\n\";\n12.\t    machine1.setNumber(100);\n13.\t    machine1.setName(\"BIT117\");\n14.\t    cout \u003c\u003c machine1.display(); \n15.\t\n16.\t    cout \u003c\u003c \"\\n===== machine1 Status (1) =====\\n\";\n17.\t    machine1.status();  // status() function displays current status of the machine.\n18.\t\n19.\t    machine1.refill(5, 7, 3, 10); // A machine’s admin can refill the items.\n20.\t\n21.\t    cout \u003c\u003c \"\\n===== machine1 Status (2) =====\\n\";\n22.\t    machine1.status();\n23.\t\n24.\t    cout \u003c\u003c endl;\n25.\t    machine1.displayMenu();\n26.\t\n27.\t    cout \u003c\u003c endl;\n28.\t    machine1.selectItem();   // A user can select item(s).\n29.\t\n30.\t    cout \u003c\u003c \"\\n===== machine1 Payment (1) =====\\n\";\n31.\t    if(machine1.payment() == true)   // Pay with a debit card or cash.\n32.\t    {\n33.\t        cout \u003c\u003c \"\\n===== Receipt (1) =====\\n\";\n34.\t        machine1.displayReceipt();\n35.\t    }\n36.\t    else \n37.\t    {\n38.\t        // Note that if a user entered incorrect payment information,\n39.\t        // all selections should be deselected.\n40.\t        cout \u003c\u003c \"Invalid payment. All selections are cancelled.\\n\";\n41.\t    }\n42.\t\n43.\t    cout \u003c\u003c \"\\n===== machine1 Status (3) =====\\n\";\n44.\t    machine1.status();\n45.\t\n46.\t    cout \u003c\u003c endl;\n47.\t    machine1.selectItem();\n48.\t\n49.\t    cout \u003c\u003c endl;\n50.\t    machine1.deselect( );  // A user can de-select items.\n51.\t\n52.\t    cout \u003c\u003c endl;\n53.\t    machine1.selectItem();\n54.\t\n55.\t    cout \u003c\u003c \"\\n===== machine1 Payment (2) =====\\n\";\n56.\t    if(machine1.payment())\n57.\t    {\n58.\t        cout \u003c\u003c \"\\n===== Receipt (2) =====\\n\";\n59.\t        machine1.displayReceipt();\n60.\t    }\n61.\t\n62.\t    cout \u003c\u003c \"\\n===== machine1 Status (4) =====\\n\";\n63.\t    machine1.status();\n64.\t\n65.\t    machine1.reset();  // An admin resets the machine to the initial \n66.\t                       // status, except the ID and name of the machine.\n67.\t    cout \u003c\u003c \"\\n===== machine1 Status (5) =====\\n\";\n68.\t    machine1.status();\n69.\t\n70.\t    cout \u003c\u003c \"\\n===== Thank you! =====\\n\";\n71.\t\n72.\t    return 0;\n73.\t}\n```\n\n## Sample Run of the Demo Program: The following presents a sample result of the demo program.\n```\n===== Welcome to CSUMB Vending Machine =====\nNumber: 0, Name: UNKNOWN\nNumber: 200, Name: Library\n\n===== Updated machine 1 Info =====\nNumber: 100, Name: BIT117\n\n===== machine1 Status (1) =====\nNumber: 100, Name: BIT117\nSold: Water: 0 / Regular Coffee: 0 / Sun Chip: 0 / Chocolate Bar: 0\nRemaining: Water: 0 / Regular Coffee: 0 / Sun Chip: 0 / Chocolate Bar: 0\nTotal Earning: $0.00\n\n===== machine1 Status (2) =====\nNumber: 100, Name: BIT117\nSold: Water: 0 / Regular Coffee: 0 / Sun Chip: 0 / Chocolate Bar: 0\nRemaining: Water: 5 / Regular Coffee: 7 / Sun Chip: 3 / Chocolate Bar: 10\nTotal Earning: $0.00\n\n===== Vending Machine Menu =====\n1.\tWater............$1.50\n2.\tRegular Coffee...$2.00\n3.\tSun Chip.........$1.00\n4.\tChocolate Bar....$2.50\n\nSelect Item: 2\nHow many do you want to buy? 2\nYou selected Regular Coffee (2)\nContinue? (Y/N) Y\n\nSelect Item: 1\nHow many do you want to buy? 1\nYou selected Water (1)\nContinue? (Y/N) N\n\n===== machine1 Payment (1) =====\nPayment Option – Debit(1) / Cash(2): 1\nEnter PIN: 7777\nValid\n\n===== Receipt (1) =====\nWater: $1.50 X 1 = $1.50\nRegular Coffee: $2.00 X 2 = $4.00\nSubtotal: $5.50\nTax (10.0%): $0.55\nTotal: $6.05\n\n===== machine1 Status (3) =====\nNumber: 100, Name: BIT117\nSold: Water: 1 / Regular Coffee: 2 / Sun Chip: 0 / Chocolate Bar: 0\nRemaining: Water: 4 / Regular Coffee: 5 / Sun Chip: 3 / Chocolate Bar: 10\nTotal Earning: $6.05\n\nSelect Item: 1\nHow many do you want to buy? 3\nYou selected Water (3)\nContinue? (Y/N) Y\n\nSelect Item: 3\nHow many do you want to buy? 5\nYou selected Sun Chip (5) – Sorry. We don’t have enough Sun Chip.\nContinue? (Y/N) Y\n\nSelect Item: 4\nHow many do you want to buy? 5\nYou selected Chocolate Bar (5)\nContinue? (Y/N) N\n\nYou de-selected \n    Water (3)\n    Chocolate Bar (5)\n\nSelect Item: 4\nHow many do you want to buy? 9\nYou selected Chocolate Bar (9)\nContinue? (Y/N) N\n\n===== machine1 Payment (2) =====\nPayment Option – Debit(1) / Cash(2): 2\nEnter Money Amount: $30.85\nChange: $6.10\n\n===== Receipt (2) =====\nChocolate Bar: $2.50 X 9 = $22.50\nSubtotal: $22.50\nTax (10.0%): $2.25\nTotal: $24.75\n\n===== machine1 Status (4) =====\nNumber: 100, Name: BIT117\nSold: Water: 1 / Regular Coffee: 2 / Sun Chip: 0 / Chocolate Bar: 9\nRemaining: Water: 4 / Regular Coffee: 5 / Sun Chip: 3 / Chocolate Bar: 1\nTotal Earning: $30.80\n\n===== machine1 Status (5) =====\nNumber: 100, Name: BIT117\nSold: Water: 0 / Regular Coffee: 0 / Sun Chip: 0 / Chocolate Bar: 0\nRemaining: Water: 0 / Regular Coffee: 0 / Sun Chip: 0 / Chocolate Bar: 0\nTotal Earning: $0.00\n\n===== Thank you! =====\n```\n\n## When you develop the program, you should consider the following conditions:\n\u003cbr\u003e\n\u003cul\u003e\n    \u003cli\u003eWhen a user types the money amount for the cash payment, you can assume that the user always types the correct money amount. For example, the user types the dollar sign ‘$’ and then number such as 30.54. You don’t need to check the validity of the money amount such as $35.345 or $12.45.34.\u003c/li\u003e\n    \u003cli\u003eAt the payment() function, if a user provides incorrect payment information such as an incorrect PIN or insufficient money amount, all selections the user chose should be de-selected.\u003c/li\u003e\n    \u003cli\u003eAt the payment() function, if a user didn’t select any items before, the function should return false because there’s nothing to pay.\u003c/li\u003e\n    \u003cli\u003eIf you have any further questions, please contact the instructor.\u003c/li\u003e\n \u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanderhelleso%2Fvendingmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanderhelleso%2Fvendingmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanderhelleso%2Fvendingmachine/lists"}