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

3. User authorization

 
내용: Authorize user before initiating any transaction 사용자가 카드 입력하여 새로운 session 시작될 때, 어떠한 거래가 시작될 때 나타남.. Atm 자체가 사용자 정보를 가지고있지 않으므로 은행으로부터 정보를 받아서 authorize해야함 authorize된 다음에는 session 끝나기 전까지 거래 여러번 수행 가능
 
필요한 변수: Account* account : session 돌아가는 계좌에 대해 받은 input 포인터 변수 Bank* bank : session 돌아가는 계좌의 은행 int password : 입력받을 비밀번호 int count : 틀린 횟수 추적 변수
 
필요한 함수: Bank::verifyPassword(account, password) : Back class 내부에서 입력받은 계좌와 비밀번호에 대해 비밀번호가 계좌에 맞는 비번인지 확인하는 함수 Account::getPassword() : 해당 계좌의 비밀번호 반환 ATM::authorization() : authorization 끝나면 true, 실패하면 false 반환함
// class 선언 class Account{ private: int id; int password; public: int getPassword(); } class Bank{ private: // account들 저장... public: bool verifyPassword(Account* account, int pw); } class ATM{ private: Account* account; // 입력받을 카드에 대해 account 변수 선언 Bank* bank int password; int count = 0; public: bool authorization() } // Account 함수 int Account::getPassword(){ return this->password; } // Bank 함수 bool Bank::verifyPassword(Account* account, int pw){ if (account->getPassword() == pw){ return true; } else{ return false; } } // ATM 함수 bool ATM::authorization(){ // REQ3.1 카드가 atm 기기의 타입에 맞는 유효한 카드인지 확인함 // (See REQ in System Setup which card is considered valid) // 어떻게 입력받을지 생각해야함… cout << "Insert card: "; cin << account; // 카드 입력받음 cout << endl; // REQ3.2 유효하지 않으면 -> display error message(ex.”Invalid Card”) // !!! 유효하지 않다는게 해당 ATM에서 수행 가능한 은행 카드인지 확인하는것..인가? !!! if (account invalid함) { cout << "[ERROR] Invalid Card" << endl; return false; } // REQ3.3 사용자가 비밀번호를 입력하게하여 맞는지 확인 // ( the card and password information need to be passed to the bank; // then, the bank verifies the password, and return the authorization result.) // REQ3.4 비밀번호 틀렸으면 -> display error message (ex”Wrong Password”) cout << "Insert password: "; cin << password; while( bank->verifyPassword(account, password) != true) { cout << "[ERROR] Incorrect Password" << ends; count++; // REQ3.5 연속으로 3번 틀리면 session 끝나야함 if (cout == 3){ return false; // 여기선 비밀번호 틀림... } // 비밀번호 입력 횟수 3번 미만이면 다시 비밀번호 입력받음 cout << "Insert password: "; cin << password; cout << endl; } return true; // 여기선 비밀번호 맞음... }