내용:
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; // 여기선 비밀번호 맞음... }
![[Notion] :](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fc0389671-d63b-4c5d-a65d-5113fb1666a2%2Faf276f8d-c43c-4190-a784-11927a8f1c86%2F%25EB%2585%25B8%25EC%2585%2598_%25EC%2595%2584%25EC%259D%25B4%25EC%25BD%2598.png?table=block&id=244dd211-78d0-4c22-8c35-2efb01da5258&cache=v2)