From 3799dd975332953d86c028f72cf8edc136facedc Mon Sep 17 00:00:00 2001 From: Ilja <100518672+diliny867@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:15:06 +0200 Subject: [PATCH] Add project source files --- Team_Project/ATM.h | 140 ++++++++++ Team_Project/Coffee.h | 306 ++++++++++++++++++++++ Team_Project/Source.cpp | 14 + Team_Project/Team_Project.vcxproj | 41 +-- Team_Project/Team_Project.vcxproj.filters | 13 + Team_Project/receipt.txt | 25 ++ 6 files changed, 519 insertions(+), 20 deletions(-) create mode 100644 Team_Project/ATM.h create mode 100644 Team_Project/Coffee.h create mode 100644 Team_Project/Source.cpp create mode 100644 Team_Project/receipt.txt diff --git a/Team_Project/ATM.h b/Team_Project/ATM.h new file mode 100644 index 0000000..b18e309 --- /dev/null +++ b/Team_Project/ATM.h @@ -0,0 +1,140 @@ +#pragma once + +#include +#include + +#define HARDCODED_MAGIC_NUMBER 365 + +namespace ATM{ + using std::endl,std::string; + using std::cout; + using std::cin; + + int main() + { + int choice = 0;//Data validation pirmejam menu + + do + { + cout << "\nMenu\n" << endl + << "1 - Quit\n" + << "2 - withdraw\n" + << "3 - take a loan\n" + << "4 - deposit\n" + << "5 - account ballance\n" + << "6 - MAINTENANCE\n" + << "Enter your choice and press return: "; + std::cin >> choice; + switch(choice) + { + case 1://power off opcija + cout << "Farewell"; + return 0; + case 2://naudas izsniegšanas kods + cout << "how much would you like to withdraw?\n"; + + int money;//kods kas nosaka vai nauda kontā ir pietiekami, lai izsniegtu + cout << " Enter the amount: "; + std::cin >> money; + if(money >= HARDCODED_MAGIC_NUMBER) { + cout << "You dont have the funds for this action\n"; + break; + } else + { + cout << "Your cash has been delt\n"; + } + break; + + + case 3://kods priekš lone funkcijas + int loan; + cout << "insert the amount that you would like to borrow: "; + std::cin >> loan; + if(loan >= 0) { + cout << "Thank you for choosing markuss bank for your loans...\nCounting your money\nSucces\n"; + break; + } else + {//neļauj ievadīt negatīvus skaitļus + cout << "\nError\n"; + } + break; + case 4: + cout << " insert your card\n"; + + int cardInfo;// attiecīgais int priekš noteiktās darbības + cout << " Enter the amount you would like to deposit: "; + std::cin >> cardInfo; + if(cardInfo >= 0) + { + cout << "Thank you for choosing markuss bank the only bank you need. The funds have been added to your account\n"; + break; + } else + {//neļauj ievadīt negatīvus skaitļus + cout << "\nError\n"; + } + + break; + case 5://balance info + cout << "\nYou have 365$\n"; + break; + case 6: + int MAINTENANCE();//kods kas ļauj pikļūt pie MAINTENANCE MODE + { + int msgboxID = MessageBox( + NULL, + (LPCWSTR)L"\nDo you want to enter MAINTENANCE MODE?", + (LPCWSTR)L"", + MB_ICONASTERISK | MB_YESNO | MB_DEFBUTTON2 + ); + switch(msgboxID) + { + case IDNO: + + break; + case IDYES: + string username; + string password; + int otherchoice = 0; + cout << "Please input admin username : "; cin >> username; + cout << "Please input admins password : "; cin >> password; + if(username == "Markuss") { + if(password == "123") { + cout << "you are online admin\n" //ievadot pareizos datus atveras jauns menu + << "\nAdmins Menu\n\n" + << "1 - System requirement info\n" + << "2 - Turn of the device\n" + << "Enter your choice and press return: "; + std::cin >> otherchoice; + switch(otherchoice) + { + case 1: + cout << "\n*standard atm stuff*\n"; + break; + case 2: + return 0; + + } + } else + { + cout << "Invalid password! " << endl; + } + } else + { + cout << "Invalid username! " << endl; + } + + break; + + } + + break; + } + + break; + + } + } + + while(choice != 1); + } +} \ No newline at end of file diff --git a/Team_Project/Coffee.h b/Team_Project/Coffee.h new file mode 100644 index 0000000..8c4af1c --- /dev/null +++ b/Team_Project/Coffee.h @@ -0,0 +1,306 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Coffee { + +#pragma warning(disable : 4996) + + int DisplayMessageBox(LPCWSTR msg) { + int msgboxID = MessageBox( + NULL, + msg, + (LPCWSTR)L"Error", + MB_ICONERROR | MB_RETRYCANCEL | MB_DEFBUTTON2 + ); + + switch(msgboxID) { + case IDCANCEL: + break; + case IDRETRY: + + break; + } + return msgboxID; + } + + bool isString(std::string s) { + for(int i = 0; i < s.length(); i++) { + if(isdigit(s[i])) { + return false; + } + } + return true; + } + + int inputInt() { //we use it to input int + int x; + while(!(std::cin >> x)) { + std::cout << "Error!\nPlease enter number!\n"; + std::cin.clear(); + std::cin.ignore(9223372036854775807, '\n'); //cin.ignore(numeric_limits::max()); (max possible long long) + } + return x; + } + + std::string inputString() { //we use it to input string + std::string s; + std::cin >> s; + return s; + } + + + class Drink { + public: + int price; + std::string name; + std::string view; + Drink(std::string s, double p,std::string n) : //constructor + view(s), + price(p), + name(n) + {} + bool canBuy(double cash) { //check if we can buy drink + if(price <= cash) { + return true; + } + return false; + } + }; + //Initialize Drink type objects, we input ascii art, price, name + Drink tea(" ) (\n ( ) )\n ) ( (\n _______)_\n .-'---------|\n( C|/\\/\\/\\/\\/|\n '-./\\/\\/\\/\\/|\n '_________'\n '-------'\n", 200, "Tea"); + Drink coffee(" )))\n (((\n +-----+\n | |]\n `-----'\n___________\n`---------'\n", 200, "Coffee"); + Drink hotChocolate(" ( (\n ) )\n ........\n | |]\n \\ /\n `----'\n", 300, "Hot Cohocolate"); + Drink latte(" /#/\n _---------//_\n ( / )\n /=============\\\n(///////////////)\n \\ /\n C===========O \n", 200, "Latte"); + Drink cappucino(" ..\n .. ..\n ..\n ..\n ..\n ..\n ..\n## .. ####\n##.............## ##\n##.............## ##\n##.............## ##\n##.............###\n ##...........##\n #############\n #############\n#################\n", 250, "Cappucino"); + + class CoffeeMachine { + private: + bool admin; + bool saveReceipt; + int receiptCount; + public: + CoffeeMachine() : //constructor + admin(false), + saveReceipt(false), + receiptCount(0) + {} + void pour(Drink& drink) { //show drink + std::cout << "Pouring the drink...\n"; + std::cout << drink.view; + } + void buy(Drink& drink) { //buy drink + if(saveReceipt) { //save receipt + receiptCount++; + std::ofstream receiptFile; //create ofsteam object + //string name = "Receipt No"+to_string(receiptCount); + //name.append(".txt"); + std::string name ="receipt.txt"; + receiptFile.open(name,std::ios::app); //create and open new receipt file + time_t timeNow = time(0); + receiptFile << "Receipt:\n"; + receiptFile << "Time: " << ctime(&timeNow); //write currect time to receipt + receiptFile<<"You ordered: "<Release x64 - 17.0 @@ -53,27 +52,24 @@ true Unicode - - + + + + + + + + + + + + + - - - - - - - - - - - - - - Level3 @@ -130,9 +126,14 @@ true - - + + + + + + + - + \ No newline at end of file diff --git a/Team_Project/Team_Project.vcxproj.filters b/Team_Project/Team_Project.vcxproj.filters index a8a6563..acc9d66 100644 --- a/Team_Project/Team_Project.vcxproj.filters +++ b/Team_Project/Team_Project.vcxproj.filters @@ -14,4 +14,17 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + Header Files + + + Header Files + + + + + Source Files + + \ No newline at end of file diff --git a/Team_Project/receipt.txt b/Team_Project/receipt.txt new file mode 100644 index 0000000..4899d3a --- /dev/null +++ b/Team_Project/receipt.txt @@ -0,0 +1,25 @@ +Receipt: +Time: Fri Jan 26 11:24:07 2024 +You ordered: Tea +The drink cost: 200 rubles + +Receipt: +Time: Fri Jan 26 11:24:08 2024 +You ordered: Coffee +The drink cost: 200 rubles + +Receipt: +Time: Fri Jan 26 11:24:09 2024 +You ordered: Hot Cohocolate +The drink cost: 300 rubles + +Receipt: +Time: Fri Jan 26 11:24:10 2024 +You ordered: Latte +The drink cost: 200 rubles + +Receipt: +Time: Fri Jan 26 11:24:12 2024 +You ordered: Cappucino +The drink cost: 250 rubles +