A Guide To Advanced Java - Introduction to Threads pptx

2 291 1
A Guide To Advanced Java - Introduction to Threads pptx

Đang tải... (xem toàn văn)

Thông tin tài liệu

A Guide To Advanced Java Assignments © 2007 Aptech Ltd Version 1.0 Page 1 of 2 I I n n t t r r o o d d u u c c t t i i o o n n t t o o T T h h r r e e a a d d s s Sr. No. Assignment Question 1 United Bank is an esteemed bank that provides various banking services. Its services include receiving deposits of money, lending money and processing transactions. The management of United Bank is looking at automation as a means to save time and effort required in their work. In order to achieve this, the management has planned to computerize the process of transferring money from one account to another while maintaining the same total value. The United Bank Manager and a team of experts have chosen your company to provide a solution for the same. Consider yourself to be a part of the team that implements the solution for designing the application. Create an application using Threads to implement the application. The application should consist of the following classes: 1. CustomerAccount.java 2. TransferManager.java 3. AccountManager.java Each file has a specific purpose and functionality. The descriptions of each file are as follows: CustomerAccount.java The CustomerAccount class is used to store the information, such as account type and balance amount for the customer account. The CustomerAccount class contains instance variables accountType and balance to store the account type and the balance amount respectively. Create a getter method named getAccountType() to retrieve the account type of the customer. Similarly, create another getter method named getBalance() to retrieve the balance amount of the customer. Further, create a setter method named setBalance() to set the balance amount of the customer. TransferManager.java The TransferManager class demonstrates the use of Runnable interface to transfer money from one account to another while maintaining the same total value over the two accounts. The TransferManager class contains instance variable transferCount to store the count for the number of transfer instances that will take place. The run() method is implemented in this class and when it is invoked, it transfers money from one account to another while maintaining the same total value over two accounts. A Guide To Advanced Java Assignments © 2007 Aptech Ltd Version 1.0 Page 2 of 2 AccountManager.java The AccountManager class demonstrates creation of Thread objects using Runnable interface to display the total balance before transfer and after transfer. Create two threads and initiate the execution of both the threads. Display the Total balance before transfer and after transfer where both the amount should be the same. . following classes: 1. CustomerAccount .java 2. TransferManager .java 3. AccountManager .java Each file has a specific purpose and functionality. The descriptions of each file are as follows:. 1.0 Page 2 of 2 AccountManager .java The AccountManager class demonstrates creation of Thread objects using Runnable interface to display the total balance before transfer and after transfer customer. TransferManager .java The TransferManager class demonstrates the use of Runnable interface to transfer money from one account to another while maintaining the same total value

Ngày đăng: 02/08/2014, 08:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan