HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
장지원 페이지/
[Notion] :
[Notion] :
/
🏧
ATM
/남수민/
4. Deposit

4. Deposit

 
내용: o A user can deposit cash or checks to an ATM via Cash/Check Insert and Dispenser Slot. o There is a limit in the number of cash or checks that can be deposited per transaction (e.g., 50 paper cashes, 30 paper checks) 거래 당 이체 가능한 현금/수표에 개수 제한 있음
 
필요한 변수: Account* account : session 진행되고 있는 계좌 Bank* bank : account 계좌의 은행 int cash_limit : 한번에 받을 수 있는 현금 장수 제한 int check_limit = 30 : 한번에 받을 수 있는 수표 장수 제한 int available_cash : ATM 기기에 있는 현금
 
필요한 함수: void Account::setBalance(int new_balance) void Account::getBalance() void Bank::setDeposit(Account* account, int deposit_amount) void ATM::deposit()
내용:
o A user can deposit cash or checks to an ATM via Cash/Check Insert and Dispenser Slot. o There is a limit in the number of cash or checks that can be deposited per transaction (e.g., 50 paper cashes, 30 paper checks) 거래 당 이체 가능한 현금/수표에 개수 제한 있음
 
필요한 변수:
 
필요한 함수:
 
 
// class 선언 class Account{ private: int balance; // 잔고 public: void setBalance(int new_balance); void getBalance(); } class Bank{ private: // account들 저장... public: void setDeposit(Account*, int); } class ATM{ private: Account* account; // session 진행되고 있는 계좌 Bank* bank; // account 계좌의 은행 int cash_limit = 50; // 한번에 받을 수 있는 현금 장수 제한 (50은 임의로 놓은 숫자) int check_limit = 30; // 한번에 받을 수 있는 수표 장수 제한 (30은 임의로 놓은 숫자) int available_cash = ??; // ATM 기기에 있는 현금 public: void deposit() } // Account 함수 void Account::setBalance(int new_balance){ this->balance = new_balance } void Account::getBalance(){ return this->balance } // Bank 함수 void Bank::setDeposit(Account* account, int deposit_amount){ account->setBalance(account->getBalance() + deposit_amount); } // ATM 함수 void ATM::deposit(){ int deposit_type; int deposit_amount; int total_deposit; // REQ4.1 현금/수표 입력받음 cout << "What are you depositing?"; cout << "Insert 1 for cash deposit and 2 for check deposit. : " << endl; cin << deposit_type; cout << endl; // cash deposit 선택함 if (deposit_type==1){ cout << "Insert the amount of cash you want to deposit." << endl; cin << deposit_amount; // 정확히 얼마짜리 지폐가 몇장 들어왔는지도 입력되어야하는가... cin << total_deposit; // 일단 임의로 총 금액 입력받는걸 가정 // REQ4.2 개수 제한 넘으면 display error message if( deposit_amount > cash_limit){ cout << "[ERROR] " << endl; return // !!! 에러 발생하면 바로 반환되는가, 아니면 while loop 이용해서 다시 입력받는가.. } // REQ4.4 이체 수수료 부과될 수 있음 if (non-primary bank deposit임){ total_deposit += 1000; } // REQ4.3 현금/수표 accept됨 -> 은행 계좌에 거래 결과 반영 // 계좌 잔액에 총 예금액 더해주는 Bank 클래스 함수 bank->setDeposit(account, total_deposit); // REQ4.5 현금 -> ATM 기기의 available cash 늘어남 available_cash += deposit_amount; // 얼마짜리 지폐인지에 대한건 일단 고려 x } // check deposit 선택함 else if (deposit_type==2){ cout << "Insert the amount of check you want to deposit." << endl; cin << deposit_amount; // 정확히 얼마짜리 수표가 몇장 들어왔는지도 입력되어야함… cin << total_deposit; // 일단 임시로 총 금액 입력받는걸 가정 // REQ4.2 개수 제한 넘으면 display error message if( deposit_amount > check_limit){ cout << "[ERROR] " << endl; return // !!! } // REQ4.4 이체 수수료 부과될 수 있음 if (non-primary bank deposit임){ total_deposit += 1000; } // REQ4.3 현금/수표 accept됨 -> 은행 계좌에 거래 결과 반영 // 계좌 잔액에 총 예금액 더해주는 Bank 클래스 함수 bank->setDeposit(account, total_deposit); // REQ4.6 수표 -> available cash 변화x } // 예외사항… else { cout << “[ERROR] “ << endl; } }