Return new void register(String name, String password, int initialAmount) Public static BankService requestBankService() Must be accessible to clients only through interfaces package In real world banking, manny problems could happen when you use its services. Now lets try to transfer too large amount of money (smith.getName() + " has " + smith.getAvailableMoney() + "$") (smith.getName() + " has " + john.getAvailableMoney() + "$") (john.getName() + " has " + john.getAvailableMoney() + "$") Public static void main(String args) throws īankService bankService = Bank.requestBankService() //Request bank service (same as you'd go to banks website)īankService.register("John", "hero", 100) īankService.register("Smith", "superHero", 100) ĪccountService john = bankService.logIn("John", "hero") ĪccountService smith = bankService.logIn("Smith", "superHero") It lacks many aspects such as Security, Transactions service, Persistency and many others but it is enaugh of it to show you a Big Picture.īanking.java (Client) package You just send request to banking system to reduce amount of money in your account and add that amount to target account. When you transfer money from your account it is not you that reduces amount of money in your account. You wouldn't be able to access bank account without bank service. Bank account would not exist without bank. In OOP world it is better to try to keep as closer to real world counterparts as possible.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |