美女扒开腿免费视频_蜜桃传媒一区二区亚洲av_先锋影音av在线_少妇一级淫片免费放播放_日本泡妞xxxx免费视频软件_一色道久久88加勒比一_熟女少妇一区二区三区_老司机免费视频_潘金莲一级黄色片_精品国产精品国产精品_黑人巨大猛交丰满少妇

代做UIC's finance office.、代寫java編程語言

時間:2024-05-30  來源:  作者: 我要糾錯



Project Requirements 
question 1 
In this project you need to write software for UIC's finance office. The finance office deals with the finances of different 
kinds of people at UIC: students who pay money for their tuitions, employees who receive money for their salaries, etc. 
All these people pay or receive a certain amount of money, expressed in yuans. 
Write a Payer interface for people who pay money to the finance office, with the following UML specification: 
+-------------------------------+ 
| <<interface>> | 
| Payer | 
+-------------------------------+ 
| + getName(): String | 
| + getDebt(): int | 
| + pay(int amount): void | 
+-------------------------------+ 
and a Person class that implements Payer and has the following UML specification: 
+------------------------------------+ 
| Person | 
+------------------------------------+ 
| - name: String | 
| - debt: int | 
+------------------------------------+ 
| + Person(String name, int debt) | 
| + getName(): String | 
| + getDebt(): int | 
| # setDebt(int debt): void | 
| + pay(int amount): void | 
| + testPerson(): void | 
+------------------------------------+ 
The name instance variable indicates the name of the Person. The debt instance variable indicates the amount of money 
that the person must pay to UIC (to simplify the assignment we will assume that money is always expressed as an integer 
number of yuans). 
The setDebt method changes the amount of debt that a person has. The setDebt method is protected, not 
public. This means that only subclasses of the Person class can use the setDebt method. All the other classes in the 
software cannot use the setDebt method, so they cannot change the amount of debt a person has, which is good for 
security. 
The purpose of the pay method is to decrease or increase the amount of debt a person has (depending on what kind of 
person it is) by the amount given as argument to the method. The pay method of the Person class is abstract, since 
we do not know what kind of person the person is (a person paying money or a person receiving money). question 2 
Add a class Student that extends Person. The constructor of the Student class takes as arguments a name and the 
amount of UIC debt that the student has (because the student needs to pay tuition or pay for the dormitory, for example). 
The Student class does not have any instance variable. 
The pay method of the Student class makes the student pay money to UIC, which decreases the amount of debt that 
the student has by the amount of money given as argument to the method. A student can have a negative debt (meaning 
that the student paid too much to UIC, which always makes UIC happy). 
question 3 
Add a class Employee that extends Person. The constructor of the Employee class takes as arguments the name of 
the employee and the salary that UIC must pay to the employee. If the salary given as argument is strictly less than zero 
then the constructor must throw a NegativeSalaryException with the message "An employee cannot have 
a negative salary!" The Employee class does not have any instance variable. 
Warning: the constructor of the Employee class takes as argument the salary of the employee (the amount of money 
that UIC must pay to the employee) but the debt instance variable of the Person class indicates how much money the 
person must pay to UIC. Therefore a positive salary is the same as a negative debt. 
The pay method of the Employee class makes UIC pay money to the employee, which decreases the current salary of 
the employee by the amount of money given as argument to the method (so the debt of the employee becomes less 
negative!) For example, if an employee currently has a salary of 10000 yuans (-10000 yuans of debt) and pay(2000) is 
called then the employee's salary becomes 8000 yuans (-8000 yuans of debt, meaning that UIC still needs to pay an extra 
8000 yuans to the employee after paying the 2000 yuans). It is fine for the pay method to be given a negative value as 
argument, which means the employee then just receives a salary increase. For example, if an employee currently has a 
salary of 10000 yuans and pay(-2000) is called then the employee's salary becomes 12000 yuans. An employee cannot 
be overpaid money by UIC though, so the current salary of the employee must always be positive or zero, never negative 
(the debt of the employee cannot be positive). If the argument given to the pay method is too positive and would change 
the employee's salary to become negative, then instead the current salary of the employee must not change and the pay 
method must throw a NegativeSalaryException with the message "An employee cannot be overpaid 
by XXX yuans!", where XXX is replaced with the amount of the overpayment. For example, if an employee currently 
has a salary of 10000 yuans and pay(12000) is called then the employee still has a salary of 10000 yuans and the 
method throws a NegativeSalaryException with the message "An employee cannot be overpaid by 
2000 yuans!" 
Note: to simplify the project, do not worry about the setDebt method. 
Change other classes and interfaces as necessary. 
question 4 
Add a class FacultyMember that extends Employee. The constructor of the FacultyMember class takes as 
arguments the name of the faculty member and the salary that UIC must pay to the faculty member. The 
FacultyMember class does not have any instance variable. 
The pay method of the FacultyMember class makes UIC pay money to the faculty member, which decreases the 
current salary of the faculty member by the amount of money given as argument to the method (so the debt of the faculty member becomes less negative!) In addition to the normal salary, a faculty member might also temporarily borrow extra 
money from UIC that the faculty member will need to reimburse later, so the salary of a faculty member might then 
become negative (the debt becomes positive) without throwing any exception: a negative salary (positive debt) then just 
means that the faculty member has temporarily borrowed some money. 
Change other classes and interfaces as necessary. 
question 5 
Add a FinanceOffice class with the following UML specification: 
+--------------------------------------------+ 
| FinanceOffice | 
+--------------------------------------------+ 
| - name: String | 
| - payers: ArrayList<Payer> | 
+--------------------------------------------+ 
| + FinanceOffice(String name) | 
| + addPayer(Payer payer): void | 
| + totalDebt(): int | 
| + getDebt(String name): int | 
| + pay(String name, int amount): void | 
| + testFinanceOffice(): void | 
+--------------------------------------------+ 
When a finance office is created, it has an arraylist of payers but the arraylist is empty (the arraylist does not contain any 
payer). 
The addPayer method takes a payer as argument and adds the payer to the arraylist of payers for the finance office. 
The totalDebt method returns as result the total amount of debt of all the payers of the finance office (if the result is 
positive then it means that the finance office will receive more money from all the students (and the faculty members 
with debts) than it needs money to pay all the salaries of the employees and UIC will then make a profit; if the result is 
negative then it means that the finance office will not get enough money from the students and will need to borrow extra 
money from a bank to be able to pay all the employees, otherwise UIC will go bankrupt; if the result is zero then it means 
that the money paid by all the students will exactly cover the salaries of the employees). 
The getDebt method takes as argument the name of a payer and returns as result the current amount of debt for this 
payer. If the finance office does not have a payer with the correct name then the getDebt method must throw an 
UnknownPayerException with the message "Payer XXX unknown", where XXX is replaced with the name of 
the payer. Do not worry about multiple payers having the same name. 
The pay method takes as argument the name of a payer and an amount of money and uses the pay method of that payer 
to pay that amount of money to that payer. If the finance office does not have a payer with the correct name then the 
pay method must throw an UnknownPayerException with the message "Payer XXX unknown", where XXX is 
replaced with the name of the payer. Do not worry about multiple payers having the same name. 
Note: the pay method does not catch any exception, it only throws exceptions. 
question 6 
In this question and the next one we want to create a command line interface (CLI) for our finance office software. Add a CLI class with a main method. Your code then has two classes with a main method: the Test class that you can 
use to run all your tests for all your classes, and the CLI class that you will now use to run the interactive text-based 
interface of your program. 
The CLI class does not have any testCLI method because this class is only used to allow users to use the software 
interactively. 
Add to the CLI class a private static input instance variable which is a Scanner object that reads input from the 
standard input stream System.in: 
 private static Scanner input = new Scanner(System.in); 
Always use this input scanner object when you need to read input. (Never close this scanner object, because this would 
also close the standard input stream System.in, and then the next time you tried to read something from the standard 
input stream you would get a NoSuchElementException!) 
In addition to the main method and the input instance variable, the CLI class has two methods called readLine and 
readPosInt. 
The readLine method is static and private, it takes a string as argument, and returns another string as result. The 
readPosInt method is static and private, it takes a string as argument, and returns a positive integer as result. 
The readLine method uses System.out.print (not println) to print its string argument on the screen (later 
when we use the readLine method, the string argument of the method will be a message telling the user to type some 
text). Then the readLine method uses the input scanner object to read a whole line of text from the user of the 
program and returns the text as result. 
The readPosInt method uses System.out.print (not println) to print its string argument on the screen (later 
when we use the readPosInt method, the string argument of the method will be a message telling the user to type some 
integer). Then the readPosInt method uses the input scanner object to read an integer from the user of the program. 
After reading the integer, the readPosInt method must also use the scanner's nextLine method to read the single 
newline character that comes from the user pressing the Enter key on the keyboard after typing the integer (if you do 
not read this newline character using the nextLine method inside the readPosInt method, then the newline 
character will remain in the input stream, and, the next time you use the readLine method described above, the 
readLine method will just immediately read only the newline character from the input stream and return an empty 
string as result, without waiting for the user to type anything!) 
If the user types something which is not an integer, then the nextInt method of the scanner will throw an 
InputMismatchException. In that case the code of your readPosInt method must catch the exception, use 
System.out.println to print the error message "You must type an integer!" to the user (use 
System.out.println for this, not System.err.println, otherwise you might hit a bug in Eclipse...), use the 
scanner's nextLine method to read (and ignore) the wrong input typed by the user of the program (if you do not do 
this, the wrong input typed by the user will remain in the input stream, and the next time you call the nextInt method 
again, you will get an InputMismatchException again!), and then do the whole thing again (including printing again 
the string argument of the readPosInt method) to try to read an integer again (hint: put the whole code of the method 
inside a while loop). 
After reading the integer and the newline character (which is just ignored), the readPosInt method tests the integer. 
If the integer is bigger than or equal to zero, then the readPosInt method returns the integer as result. If the integer is strictly less than zero, then the readPosInt method uses System.out.println to print the error message 
"Positive integers only!" to the user (use System.out.println for this, not System.err.println, 
otherwise you might hit a bug in Eclipse...), and then does the whole thing again (including printing again the string 
argument of the readPosInt method) to try to read an integer again (hint: just print the error message, and then the 
while loop you already have around the whole code will automatically do the whole thing again...) 
For example, if you want to check that your two methods readLine and readPosInt work correctly, put the following 
code in the main method of your CLI class: 
 public static void main(String[] args) { 
 String str1 = readLine("Type some text: "); 
 System.out.println("Text read is: " + str1); 
 int i = readPosInt("Type an integer: "); 
 System.out.println("Integer read is: " + i); 
 String str2 = readLine("Type some text again: "); 
 System.out.println("Text read is: " + str2); 
 } 
then running the main method of the CLI class should look like this (where aaaa bbbb, cccc, dddd eeee, -100, 
-200, 1234, and ffff gggg are inputs typed by the user on the keyboard): 
Type some text: aaaa bbbb 
Text read is: aaaa bbbb 
Type an integer: cccc 
You must type an integer! 
Type an integer: dddd eeee 
You must type an integer! 
Type an integer: -100 
Positive integers only! 
Type an integer: -200 
Positive integers only! 
Type an integer: 1234 
Integer read is: 1234 
Type some text again: ffff gggg 
Text read is: ffff gggg 
question 7 
Once you have checked that your methods readLine and readPosInt work correctly, remove all the code inside the 
main method of the CLI class so that the main method is empty again. 
In the rest of this question, use the readLine and readPosInt methods every time your program needs to read a 
string or an integer from the user. 
In the empty main method of the CLI class, create a single FinanceOffice object with the name "UIC FO". The 
main method of the CLI class must then print a menu that allows the user of your software to do six different actions 
that involve the finance office object, and your program must then read an integer from the user that indicates which 
action must be performed by the program (see below for the details of each action). Use the readPosInt method to 
print the menu (give the string for the menu as the argument of readPosInt) and to read the integer typed by the user. 
For example, the menu should look like this: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
The user then types an integer between 1 and 6 to select the action. For example (where 3 is an input from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
and your program then performs the selected action. 
After an action has been performed by your program, your program must again print the menu and ask again the user of 
the program for the next action to perform (hint: put the whole code of the main method inside a while loop, except 
for the one line of code that creates the single finance office object). 
If the user types an integer which is not between 1 and 6, then your program must print an error message "Unknown 
action!" to the user (hint: when testing the integer for the action, use the default case of a switch statement) 
and then print the menu again (by just going back to the beginning of the while loop). 
For example (where 7 is an input from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 7 
Unknown action! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
If the user types something which is not an integer, the readPosInt method that you implemented in the previous 
question will automatically repeat the menu and ask the user to type an integer again until the user actually types an 
integer, so you do not have to worry about this in the code of the main method of your CLI class. 
For example (where aaaa and bbbb cccc are inputs from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): aaaa 
You must type an integer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): bbbb cccc 
You must type an integer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Here are the detailed explanations for each action. 
Action 1: printing the total amount of debt. 
When the user of the software specifies action 1, your program must simply print on the screen the total amount of debt 
for all the payers of the finance office. Then your program goes back to printing the menu of actions (by just going back 
to the beginning of the while loop). 
For example (where 1 is an input from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 2000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Action 2: adding a new payer to the finance office. 
When the user of the software specifies action 2, your program must add a new payer to the finance office. To add a new 
payer, your program needs to ask the user three things: the type of payer (an integer read using readPosInt: the integer 
1 represents a student, the integer 2 represents an employee, the integer 3 represents a faculty member, and any other 
integer must result in an error message "Unknown type of payer!" being printed and the software going 
immediately back to the main menu), the name of the payer (a string read using readLine), and the initial amount of 
money for the debt (for a student) or the salary (for an employee or a faculty member) when the payer is created. You 
program must then create the correct payer, add it to the finance office, and print an information message for the user of 
the software. The program then goes back to the menu. For example (where 1, 2, -100, 4, 2, 1, UIC Student, 5000, 1, 2, 2, Daniel, 1000, 1, 2, 3, Thompson, 2000, and 
1 are inputs from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 0 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): -100 
Positive integers only! 
Enter the payer type (student:1 employee:2 faculty member:3): 4 
Unknown type of payer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 1 
Enter the name of the payer: UIC Student 
Enter the initial amount of money: 5000 
Student "UIC Student" with 5000 yuans of debt added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 5000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 2 
Enter the name of the payer: Daniel 
Enter the initial amount of money: 1000 
Employee "Daniel" with 1000 yuans of salary added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 4000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 3 
Enter the name of the payer: Thompson 
Enter the initial amount of money: 2000 
Faculty member "Thompson" with 2000 yuans of salary added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 2000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Note that the readPosInt method prevents the initial amount of money from being negative, so the constructor for 
the Employee class will never throw a NegativeSalaryException when you create an employee object. 
Nevertheless the code of the main method of your CLI class must handle this exception correctly by printing the error 
message "BUG! This must never happen!" and immediately terminating the program using System.exit(1). 
The same applies to a faculty member. 
Action 3: listing the amount of debt for a given payer. 
When the user of the software specifies action 3, your program must ask the user to type the name of a payer, and the 
program then prints the amount of debt for this payer. 
For example (where 3, UIC Student, 3, Daniel, 3, and Thompson are inputs from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 5000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -2000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
If the name of the payer is wrong (the finance office does not have a payer with this name) then an 
UnknownPayerException will be thrown by the FinanceOffice object. The code of the main method of your CLI class must then catch this exception, print the error message from the exception object, and then it just goes back to 
printing the menu of actions (by just going back to the beginning of the while loop). 
For example (where 3 and aaaa are inputs from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: aaaa 
Payer aaaa unknown 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Action 4: paying money to a given payer. 
When the user of the software specifies action 4, your program must ask the user to type the name of a payer and an 
amount of money, and the program then uses that amount of money to call the pay method of the payer with that name. 
Then the program goes back to the main menu. 
For example: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 5000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: UIC Student 
Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 4000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Daniel 
Enter the amount of money: -500 
Positive integers only! 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -2000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Thompson 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -1500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
If the name of the payer is wrong (the finance office does not have a payer with this name) then an 
UnknownPayerException will be thrown by the FinanceOffice object. The code of the main method of your 
CLI class must then catch this exception, print the error message from the exception object, and then it just goes back to 
printing the menu of actions (by just going back to the beginning of the while loop). 
For example: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: aaaa 
Enter the amount of money: 1000 
Payer aaaa unknown Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
If a payer is an employee and the amount of money typed by the user is too big then a NegativeSalaryException 
will be thrown by the Employee object. The code of the main method of your CLI class must then catch this exception, 
print the error message from the exception object, and then it just goes back to printing the menu of actions (by just going 
back to the beginning of the while loop). 
For example: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Daniel 
Enter the amount of money: 1500 
An employee cannot be overpaid by 1000 yuans! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 4000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: UIC Student 
Enter the amount of money: 5000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -1500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Thompson 
Enter the amount of money: 2000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has 500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Action 5: taking money from a given payer. 
When the user of the software specifies action 5, your program must ask the user to type the name of a payer and an 
amount of money, and the program then uses that amount of money, makes it negative, and pays that negative amount 
to the payer with that name. Then the program goes back to the main menu. 
For example: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 4000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: UIC Student 
Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 5000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: Daniel Enter the amount of money: -500 
Positive integers only! 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -1500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: Thompson 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -2000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
If the name of the payer is wrong (the finance office does not have a payer with this name) then an 
UnknownPayerException will be thrown by the FinanceOffice object. The code of the main method of your 
CLI class must then catch this exception, print the error message from the exception object, and then it just goes back to 
printing the menu of actions (by just going back to the beginning of the while loop). 
For example: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: aaaa 
Enter the amount of money: 1000 
Payer aaaa unknown 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 
Note that, even if a payer is an employee, the readPosInt method prevents the amount of money typed by the user 
from being negative. This means an employee will never throw a NegativeSalaryException. Nevertheless the code 
of the main method of your CLI class must handle this exception by printing the error message "BUG! This must 
never happen!" and immediately terminating the program using System.exit(1). 
Action 6: quitting the program. 
When the user of the software specifies action 6, your program must print a "Goodbye!" message, and terminate the 
program using: System.exit(0). 
For example (where 6 is an input from the user): 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 6 
Goodbye! 
Here is a more complete example of running the software: 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): aaaa 
You must type an integer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): bbbb cccc 
You must type an integer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): -100 
Positive integers only! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 7 
Unknown action! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 0 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): -100 
Positive integers only! Enter the payer type (student:1 employee:2 faculty member:3): 4 
Unknown type of payer! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 1 
Enter the name of the payer: UIC Student 
Enter the initial amount of money: 5000 
Student "UIC Student" with 5000 yuans of debt added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 5000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 2 
Enter the name of the payer: Daniel 
Enter the initial amount of money: 1000 
Employee "Daniel" with 1000 yuans of salary added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 4000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 2 
Enter the payer type (student:1 employee:2 faculty member:3): 3 
Enter the name of the payer: Thompson 
Enter the initial amount of money: 2000 
Faculty member "Thompson" with 2000 yuans of salary added 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 2000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 5000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -2000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: aaaa 
Payer aaaa unknown 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: UIC Student 
Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 4000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Daniel 
Enter the amount of money: -1000 
Positive integers only! 
Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has 0 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Thompson 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -1500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 2500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: aaaa 
Enter the amount of money: 1000 
Payer aaaa unknown 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: UIC Student Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has 5000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: Daniel 
Enter the amount of money: -1000 
Positive integers only! 
Enter the amount of money: 1000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: Thompson 
Enter the amount of money: 500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has -2000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: 2000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 5 
Enter the name of the payer: aaaa 
Enter the amount of money: 1000 
Payer aaaa unknown 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: UIC Student 
Enter the amount of money: 6000 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: UIC Student 
UIC Student has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Daniel 
Enter the amount of money: 1500 
An employee cannot be overpaid by 500 yuans! 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Daniel 
Daniel has -1000 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 4 
Enter the name of the payer: Thompson 
Enter the amount of money: 2500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 3 
Enter the name of the payer: Thompson 
Thompson has 500 yuans of debt 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 1 
Total amount of debt: -1500 
Type an action (total:1 add:2 get:3 give:4 take:5 quit:6): 6 
Goodbye! 
question 8 
We now want to create a graphical user interface (GUI) for our finance office software. Since we want our finance office 
software to have multiple views, we will use the Model-View-Controller design pattern. 
First, create a ModelListener interface with the following UML specification: 
+-------------------+ 
| <<interface>> | 
| ModelListener | 
+-------------------+ 
| + update(): void | 
+-------------------+ This interface will be implemented by views and the model will use this interface to notify the views that they need to 
update themselves. 
Second, the FinanceOffice class is the class that contains all the data for the finance office. Therefore the 
FinanceOffice class plays the role of the model. Therefore the FinanceOffice class needs to have an arraylist of 
model listeners that needs to be notified every time the finance office (the model) changes. Therefore add to the 
FinanceOffice class an arraylist of ModelListener. Also add to the FinanceOffice class an addListener 
method that takes a ModelListener as argument and adds it to the arraylist of listeners. Also add to the 
FinanceOffice class a private notifyListeners method that takes nothing as argument and calls the update 
method of all the listeners of the finance office. Then change the addPayer and pay methods so that they call the 
notifyListeners every time a change is made to the finance office's data (only the addPayer and pay methods 
change the finance office's data, so only these two methods need to call the notifyListeners method; the 
totalDebt and getDebt methods do not change the finance office's data, they only inspect the data, so they do not 
need to call the notifyListeners method). 
Use the Test class to make sure all your tests still work. Use the CLI class to make sure your command line interface still 
works. 
Third, create a ViewSimple class that extends JFrame, implements the ModelListener interface, and has the 
following UML specification: 
+--------------------------------------------------------+ 
| ViewSimple | 
+--------------------------------------------------------+ 
| - m: FinanceOffice | 
| - c: ControllerSimple | 
| - label: JLabel | 
+--------------------------------------------------------+ 
| + ViewSimple(FinanceOffice m, ControllerSimple c) | 
| + update(): void | 
+--------------------------------------------------------+ 
The constructor of the ViewSimple class registers the view with the model (the finance office) using the addListener 
method of the model, creates a JLabel object, stores it in the label instance variable of the ViewSimple class, 
initializes the label to display the total amount of debt of all the payers of the finance office, and adds the label to the view 
(which is a frame). The update method of the ViewSimple class updates the text of the label as necessary so that 
the label always displays the current total amount of debt of all the payers of the finance office. 
Fourth, create a ControllerSimple class with the following UML specification: 
+------------------------------------------+ 
| ControllerSimple | 
+------------------------------------------+ 
| - m: FinanceOffice | 
+------------------------------------------+ 
| + ControllerSimple(FinanceOffice m) | +------------------------------------------+ 
Since the ViewSimple does not have any button, it cannot perform any action, therefore the corresponding controller 
ControllerSimple does nothing. (We still want to have the ControllerSimple class so that our application 
follows the correct Model-View-Controller design pattern.) 
Fifth, create a GUI class with a main method. In this main method, create an anonymous class that implements the 
Runnable interface with a run method and use the javax.swing.SwingUtilities.invokeLater method to 
run that code on the event dispatch thread. 
Sixth, we need to connect the model, the view, and the controller to each other. So in the run method of the anonymous 
class: 
• create a FinanceOffice object (the model object) with the name "UIC FO"; 
• then create a ControllerSimple object (the controller object) that takes the model object as argument; 
• then create a ViewSimple object that takes the model object and the controller object as arguments. 
Use the GUI class to run your GUI: you should see a window that shows the total amount of debt of all the payers of the 
finance office. This total amount must be zero, since the finance office (model object) you just created above does not 
have any payer! 
As a test, in the run method of the anonymous class, you can try to manually add to your finance office (model object) 
some students, employees, and faculty members to check that your GUI displays the correct total amount of debt for all 
the payers of the finance office. For example: 
 
question 9 
In the next questions we want to add more views. So, to simplify the next questions, create a View class which is going 
to be the superclass of all views. This View class is generic, extends JFrame, implements the ModelListener 
interface, and has the following UML specification: 
+------------------------------------------+ 
| View<T extends Controller> | 
+------------------------------------------+ 
| # m: FinanceOffice | 
| # c: T | 
+------------------------------------------+ 
| + View(FinanceOffice m, T c) | 
| + update(): void | 
+------------------------------------------+ 
The m and c instance variables of the View class are protected (so that they can be easily used in all the subclasses of 
View). In the constructor of the View class, the view registers itself with the model. The update method of the View 
class is abstract. Then modify the ViewSimple class to be a subclass of the View<…> class. The ViewSimple class must then have only 
one instance variable: the label. To simplify a little the code of the next questions, also move the 
setDefaultCloseOperation method call from the constructor of ViewSimple to the constructor of View. Also 
make sure that the ViewSimple does not directly register itself with the model anymore, since this is now done in the 
superclass View. 
Also create a Controller class which is going to be the superclass of all controllers. This Controller class has the 
following UML specification: 
+------------------------------------------+ 
| Controller | 
+------------------------------------------+ 
| # m: FinanceOffice | 
+------------------------------------------+ 
| + Controller(FinanceOffice m) | 
+------------------------------------------+ 
The m instance variable of the Controller class is protected (so that it can be easily used in all the subclasses of 
Controller). 
Then modify the ControllerSimple class to be a subclass of the Controller class. (Note: since 
ControllerSimple does nothing anyway, we could just remove it and replace it with Controller in the definition 
of ViewSimple and in the run method of the GUI class, but here we keep ControllerSimple just to make the 
Model-View-Controller design pattern very clear.) 
Run your GUI and check that it still works as before. 
question 10 
We now want to add a new “get debt” view that allows the user of the software to check how much debt a specific payer 
has. 
Create a ViewGetDebt class that extends View<ControllerGetDebt> and has the following UML specification: 
+------------------------------------------------------------+ 
| ViewGetDebt | 
+------------------------------------------------------------+ 
| - t: JTextField | 
+------------------------------------------------------------+ 
| + ViewGetDebt(FinanceOffice m, ControllerGetDebt c) | 
| + update(): void | 
+------------------------------------------------------------+ 
The ViewGetDebt shows the text field called t (where the user can type text) and a button. Use a grid layout manager 
to position the two components. For example: 
 The user can type in the text field t the name of a payer. For example: 
 
When the user then clicks on the button, the action listener of the button must read the name of the payer that was typed 
in the text field (using the getText method of the text field) and must call the getDebt method of the controller with 
that payer name as argument. The getDebt method of the controller returns a string as result which must then be 
displayed back to the user using a message dialog (using the showMessageDialog method of the JOptionPane 
class). For example: 
 
The update method of the ViewGetDebt class does nothing, because the ViewGetDebt class does not graphically 
display any data from the finance office (the model). 
Also create a ControllerGetDebt class that extends Controller and has the following UML specification: 
+--------------------------------------------+ 
| ControllerGetDebt | 
+--------------------------------------------+ 
+--------------------------------------------+ 
| + ControllerGetDebt(FinanceOffice m) | 
| + getDebt(String name): String | 
+--------------------------------------------+ 
The getDebt method takes the name of a payer as argument. The getDebt method of the controller then calls the 
getDebt method of the finance office to get the current amount of debt of that payer. The getDebt method of the 
controller then transforms the integer result of the getDebt method of the finance office into a string and returns that 
string as result (to the view). If the getDebt method of the finance office throws an UnknownPayerException then 
the getDebt method of the controller must catch this exception and return as result the error message from the 
exception object. 
Modify the run method of the GUI class to add a ViewGetDebt view that uses a ControllerGetDebt controller 
and the same model as before (not a new model!) Do not delete the previous view. 
Run your GUI and check that you can correctly use the new view to query the amount of debt of different payers of your 
finance office (obviously your finance office must have some payers to test this: see the last paragraph of question 8). 
Also check that querying the amount of debt of an unknown payer correctly shows an error message. For example:  
question 11 
We now want to add a new “pay money” view that allows the user of the software to pay money to a specific payer. 
Create a ViewPay class that extends View<ControllerPay> and has the following UML specification: 
+--------------------------------------------------------------+ 
| ViewPay | 
+--------------------------------------------------------------+ 
| - t1: JTextField | 
| - t2: JTextField | 
+--------------------------------------------------------------+ 
| + ViewPay(FinanceOffice m, ControllerPay c) | 
| + update(): void | 
+--------------------------------------------------------------+ 
The ViewPay shows the two text field called t1 and t2 (where the user can type text) and a button. Use a grid layout 
manager to position the three components. For example: 
 
The user can type in the first text field the name of a payer and can type in the second text field an amount of money. For 
example: 
 
When the user then clicks on the button, the action listener of the button must read the name of the payer that was typed 
in the first text field (using the getText method of the text field) and the amount of money that was typed in the second 
text field (using again the getText method) and must call the pay method of the controller with these two strings as 
arguments. The pay method of the controller then returns a string as result. If the string returned by the pay method of 
the controller is different from the empty string "" then this string must be displayed back to the user using a message dialog (using the showMessageDialog method of the JOptionPane class). If the string returned by the pay method 
of the controller is equal to the empty string "" then nothing happens in ViewPay. 
The update method of the ViewPay class does nothing, because the ViewPay class does not graphically display any 
data from the finance office (the model). 
Also create a ControllerPay class that extends Controller and has the following UML specification: 
+-------------------------------------------------+ 
| ControllerPay | 
+-------------------------------------------------+ 
+-------------------------------------------------+ 
| + ControllerPay(FinanceOffice m) | 
| + pay(String name, String amount): String | 
+-------------------------------------------------+ 
The pay method takes the name of a payer and an amount of money (as a string) as arguments. The pay method of the 
controller then transforms the amount of money from a string to an integer (using the Integer.parseInt static 
method) and calls the pay method of the finance office to pay the amount of money to the payer with the correct name. 
• If no exception occurs then the pay method of the controller returns the empty string. 
• If the pay method of the finance office throws an UnknownPayerException then the pay method of the 
controller must catch this exception and return as result the error message from the exception object. 
• If the pay method of the finance office throws a NegativeSalaryException then the pay method of the 
controller must catch this exception and return as result the error message from the exception object. 
• If the parseInt method of the Integer class throws a NumberFormatException (because the user typed 
something which is not an integer) then the pay method of the controller must catch this exception and return as 
result the error message from the exception object. 
Note: to keep things simple, it is allowed for a user of your software to type a negative amount of money in this “pay 
money” view, so there is no need to check for that in the controller. 
Modify the run method of the GUI class to add a ViewPay view that uses a ControllerPay controller and the same 
model as before (not a new model!) Do not delete the previous views. 
Run your GUI and check that you can correctly use the new view to pay money to different payers of your finance office 
(obviously your finance office must have some payers in it to test this: see the last paragraph of question 8). 
• Check that, when you pay money to a payer, the simple view is automatically correctly updated to show the new total 
amount of debt for all the payers of the finance office. 
• Also use the “get debt” view to check that the payer's debt correctly changed. 
• Also check that paying money to an unknown payer correctly shows an error message. For example: 
 • Also check that paying a large positive amount of money to an employee correctly shows an error message. For 
example: 
 
• Also check that trying to pay money to a payer by an amount which is not an integer correctly shows an error message 
(do not worry about the content of the error message). For example: 
 
question 12 
We now want to add a new “create” view that allows the user of the software to create a new payer for the finance office. 
Create a ViewCreate class that extends View<ControllerCreate> and has the following UML specification: 
+--------------------------------------------------------+ 
| ViewCreate | 
+--------------------------------------------------------+ 
| - t1: JTextField | 
| - t2: JTextField | 
| - cb: JComboBox<String> | 
+--------------------------------------------------------+ 
| + ViewCreate(FinanceOffice m, ControllerCreate c) | 
| + update(): void | 
+--------------------------------------------------------+ 
The ViewCreate shows the two text field called t1 and t2 (where the user can type text), the combo box cb (where 
the user can select one option from a menu) and a button. Use a grid layout manager to position the four components. 
For example: 
 The user can type in the first text field the name of a new payer and can type in the second text field an amount of money 
for the new payer. The combo box offers three menu options: "Student", "Employee", and "Faculty Member". 
For example: 
 
When the user then clicks on the button, the action listener of the button must read the name of the new payer that was 
typed in the first text field (using the getText method of the text field), read the amount of money that was typed in 
the second text field (using again the getText method), and read which menu option was selected in the combo box 
(using the getSelectedIndex method of the combo box, which returns the integer 0 or 1 or 2 depending on which 
menu option the user selected in the combo box), and calls the create method of the controller with these two strings 
and the integer as arguments. The create method of the controller then returns a string as result. If the string returned 
by the create method of the controller is different from the empty string "" then this string must be displayed back to 
the user using a message dialog (using the showMessageDialog method of the JOptionPane class). If the string 
returned by the create method of the controller is equal to the empty string "" then nothing happens in ViewCreate. 
The update method of the ViewCreate class does nothing, because the ViewCreate class does not graphically 
display any data from the finance office (the model). 
Also create a ControllerCreate class that extends Controller and has the following UML specification: 
+----------------------------------------------------------+ 
| ControllerCreate | 
+----------------------------------------------------------+ 
+----------------------------------------------------------+ 
| + ControllerCreate(FinanceOffice m) | 
| + create(String name, String amount, int type): String | 
+----------------------------------------------------------+ 
The create method takes as arguments the name of a new payer, an amount of money (as a string), and an integer 
representing the type of payer to create (where the integer 0 means a student, the integer 1 means a employee, and the 
integer 2 means a faculty member). The create method of the controller then transforms the amount of money from a 
string to an integer (using the Integer.parseInt static method), creates an object from the correct class (based on 
the type of payer specified by the user: student, or employee, or faculty member), and calls the addPayer method of 
the finance office to add the new payer object to the finance office. 
• If no exception occurs then the create method of the controller returns the empty string. 
• If the constructor of the Employee class throws a NegativeSalaryException then the create method of 
the controller must catch this exception and return as result the error message from the exception object. 
• If the parseInt method of the Integer class throws a NumberFormatException (because the user typed 
something which is not an integer) then the create method of the controller must catch this exception and return 
as result the error message from the exception object. Modify the run method of the GUI class to add a ViewCreate view that uses a ControllerCreate controller and 
the same model as before (not a new model!) Do not delete the previous views. 
Note: if at the end of question 8 you had manually added to your finance office (model object) some payers for testing, 
then you must now remove those payers from the run method of the anonymous class inside the GUI class. You do not 
need these test payers anymore because you have now a graphical user interface to create new payers! 
Run your GUI and check that you can correctly use the new view to create different payers for your finance office, with 
different types of payers. 
• Check that, when you create a new payer, the simple view is automatically correctly updated to show the new total 
amount of debt for all the payers of the finance office. 
• Also use the “get money” view to check that the payers are correctly created with the correct names and correct 
amounts of money. 
• Also check that trying to create an employee with a negative salary correctly shows an error message. For example: 
 
• Also check that trying to create a payer with an amount of money which is not an integer correctly shows an error 
message (do not worry about the content of the error message). For example: 
 
• After you have created a new payer, you can also check whether the new payer is an employee or not by using the 
“pay money” view to pay a large positive amount of money to the payer: 
o if the new payer you created is a student or a faculty member then paying a large positive amount of money will 
work and the amount of debt of the payer will change correctly (you can then check that using the “get debt” 
window); 
o if the new payer you created is an employee then paying a large positive amount of money will fail with an error 
message and the amount of debt of the employee will not change (you can then check that using the “get debt” 
window). 
question 13 
We now want to add a new “history” view that allows the user of the software to keep track of how the total amount of 
debt of all the payers of the finance office changes over time. 
Before we can add such a view to the GUI, first we need to change the model (the FinanceOffice class) to keep track 
of how the total amount of debt of all the payers of the finance office changes over time. Therefore, in the FinanceOffice class, add a new private instance variable called history which is an arraylist of integers. This 
arraylist must be initialized to contain only one value: zero (meaning that, when the finance office is created, its total 
amount of debt is zero). 
We know that the data of the finance office can change only in two methods of the FinanceOffice class: in the 
addPayer method and in the pay method (this is why these two methods both call notifyListeners: to tell the 
views that data has changed and that the views must update themselves). Therefore it is in these two methods addPayer 
and pay that we must keep track of how the total amount of debt of all the payers of the finance office changes over 
time. Therefore, in these two methods addPayer and pay, call the totalDebt method and add the result to the 
history arraylist. 
Note: in each of the two methods addPayer and pay, you must call the totalDebt method and add the result to 
the history arraylist before calling notifyListeners, otherwise the “history” view that you are going to create 
below will not show the correct results when it is notified by the finance office that it must update itself! 
Also add to the FinanceOffice class a getHistory method that returns as result the arraylist of integers which is 
the finance office's history. 
Create a HistoryPanel class that extends JPanel. The constructor of HistoryPanel takes as argument a model 
object of type FinanceOffice, which you need to store in some private instance variable. Add to the HistoryPanel 
class two private methods called historyMax and historyMin that take an arraylist of integers as argument and 
return as result the maximum and minimum number in the arraylist, respectively (you can assume that the arraylist 
contains at least one number). Then add to the HistoryPanel class a private method called historyRange that 
takes an arraylist of integers as argument and returns as result the difference between the max and min of the integers in 
the arraylist, or returns as result 200 if the difference between the man and min of the integers in the arraylist is strictly 
less than 200. 
Override the protected void paintComponent(Graphics g) method inherited from JPanel, and, inside 
your new paintComponent method, draw graphically how the total amount of debt of all the payers of the finance 
office changes over time, as follows: 
• Compute the following variables (where history is the result of calling the getHistory method of the model): 
 int min = historyMin(history); 
 int range = historyRange(history); 
 int maxX = getWidth() - 1; 
 int maxY = getHeight() - 1; 
 int zero = maxY + min * maxY / range; 
• Draw a blue line between the point (0, zero) and the point (maxX, zero) (this blue line then represents the 
horizontal “zero” axis). 
• For each value v at index i in the history arraylist that you want to draw: 
o Use x = 10 * i for the horizontal coordinate; 
o Use y = zero - v * maxY / range for the vertical coordinate; 
o Draw red lines between all the points (x, y) (if there is only one value in the arraylist then just draw a red 
rectangle of size 1 by 1 at position (x, y)). 
Create a ViewHistory class that extends View<ControllerHistory> and has the following UML specification: 
+----------------------------------------------------------+ 
| ViewHistory | 
+----------------------------------------------------------+ +----------------------------------------------------------+ 
| + ViewHistory(FinanceOffice m, ControllerHistory c) | 
| + update(): void | 
+----------------------------------------------------------+ 
The ViewHistory shows only a HistoryPanel object, nothing else. The update method of the ViewHistory 
class calls Swing's repaint method (this forces Swing to redraw everything every time the model changes, which in turn 
forces Swing to automatically call the paintComponent method of the HistoryPanel to redraw the updated version 
of the finance office's history). 
Also create a ControllerHistory class that extends Controller and has the following UML specification: 
+----------------------------------------------------------+ 
| ControllerHistory | 
+----------------------------------------------------------+ 
+----------------------------------------------------------+ 
| + ControllerHistory(FinanceOffice m) | 
+----------------------------------------------------------+ 
Since the ViewHistory does not receive any input from the user, the ControllerHistory does nothing. (Note: 
since ControllerHistory does nothing anyway, we could just remove it and replace it with Controller in the 
definition of ViewHistory and in the run method of the GUI class, but here we keep ControllerHistory just to 
make the Model-View-Controller design pattern very clear.) 
Modify the run method of the GUI class to add a ViewHistory view that uses a ControllerHistory controller 
and the same model as before (not a new model!) Do not delete the previous views. 
Run your GUI and check that adding new payers and paying money to payers correctly updates the graphical history of 
the total amount of debt for all the payers of the finance office. For example, if the user of the software creates a student 
with 2000 yuans of debt, then creates an employee with a salary of 2500 yuans, then creates a faculty member with a 
salary of 500 yuans, then pays 2000 yuans to the faculty member, then the graphical history of the finance office's total 
amount of debt must look like this (the last value is 1000 because it is the 2000 yuans of debt of the student, minus the 
2500 yuans of the salary of the employee, minus the 500 yuans of salary of the faculty member, plus the 2000 yuans paid 
to the faculty member): 
 
Check that all the other features of your software still work correctly. Also run your tests and the CLI to make sure 
everything still works correctly. 
question 14 
We now want to store the finance office's information (all the payers and the history, but not the finance office's name 
and not the finance office's listeners) into a binary file using object serialization. Add to the FinanceOffice class a new private file instance variable. In the constructor, initialize the file instance 
variable to be a File object for a binary file named "XXX.bin" (where XXX is replaced with the name of the finance 
office). Add to the FinanceOffice class a new public method called saveData that takes no argument, returns 
nothing, and uses object serialization to save into the binary file the payers and history arraylists of the finance office. 
Modify the constructor of the FinanceOffice class to read all the information from this binary file, if it exists, and put 
it into the corresponding arraylists (if the binary file does not exist then the arraylists must be initialized as before). 
Make other classes implement Java's Serializable interface as appropriate. 
Add to the Controller superclass a protected shutdown method that: 
• calls the saveData method of the model; 
• manually terminates the program using System.exit(0). 
Then modify the View superclass to: 
• hide the frame when the user clicks on the "close" button; 
• add a "window closing" event handler (use an anonymous window adapter) that calls the controller's shutdown 
method. 
Run your GUI, add some payers, make some changes to the debt or salary of some payers, exit the software, run the GUI 
again, and check that all the payers and history information is still there and is correct. Also check that the binary file is 
correctly created inside the folder for your Eclipse project (it is a binary file though, so you cannot read its content). 
Note that the command line interface that you created in question 7 reads all the information saved into the binary file 
when you start the command line interface (because the constructor of the FinanceOffice class will automatically 
read the content of the binary file if it exists and has the correct name) but it does not write the information back into the 
binary file when you quit the command line. This is easy to fix: in the main method of the CLI class, just before printing 
the "Goodbye!" message, call the saveData method of the FinanceOffice object that you created at the start of 
the main method. 
Run the command line interface and check that any change you make to the finance office's information using the 
command line interface is correctly saved into the binary file when you quit the command line interface. You can run the 
GUI to check this (but do not run the GUI and the CLI at the same time!) 
Use the Test class to run all the tests for the software and check that all the tests still work (delete the binary file before 
you do this, otherwise the FinanceOffice constructor that you use in your tests will read the payer data from the 
binary file, which will change the results of some of your tests). 
Here are a few extra instructions: 
• You should strictly follow the UML conventions when naming your class methods and class variables, otherwise, 
inconsistent naming conventions will lead to compilation failures when grading. 
• Give meaningful names to your variables so we can easily know what each variable is used for in your program. 
• Put comments in your code (in English!) to explain WHAT your code is doing and also to explain HOW your 
program is doing it. 
• Make sure all your code is properly indented (formatted). Your code should be beautiful to read. 
• In the stage of our study, packages are mutually independent, you're NOT allowed to call the class out of the 
current package. Let's take the example of Lab 4, and see the picture following.  
Failure to follow these instructions will result in you losing points.
 
請加QQ:99515681  郵箱:99515681@qq.com   WX:codinghelp
















 

標簽:

掃一掃在手機打開當前頁
  • 上一篇:代寫 CPT204 Intelligent Rogue Chars
  • 下一篇:NZDITTS5代做、代寫SQL設計編程
  • 無相關信息
    昆明生活資訊

    昆明圖文信息
    蝴蝶泉(4A)-大理旅游
    蝴蝶泉(4A)-大理旅游
    油炸竹蟲
    油炸竹蟲
    酸筍煮魚(雞)
    酸筍煮魚(雞)
    竹筒飯
    竹筒飯
    香茅草烤魚
    香茅草烤魚
    檸檬烤魚
    檸檬烤魚
    昆明西山國家級風景名勝區
    昆明西山國家級風景名勝區
    昆明旅游索道攻略
    昆明旅游索道攻略
  • 短信驗證碼平臺 理財 WPS下載

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 kmw.cc Inc. All Rights Reserved. 昆明網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    美女扒开腿免费视频_蜜桃传媒一区二区亚洲av_先锋影音av在线_少妇一级淫片免费放播放_日本泡妞xxxx免费视频软件_一色道久久88加勒比一_熟女少妇一区二区三区_老司机免费视频_潘金莲一级黄色片_精品国产精品国产精品_黑人巨大猛交丰满少妇
    五月天婷婷色综合| 波多野结衣在线网址| 激情五月深爱五月| 制服 丝袜 综合 日韩 欧美| 欧美88888| 中文字幕黄色网址| 亚洲国产欧美视频| 国产色无码精品视频国产| 国产香蕉精品视频| 国产精品综合激情| 欧美日韩人妻精品一区在线| 欧美做受高潮中文字幕 | 少妇一级黄色片| yy6080午夜| 久久久久亚洲AV成人无码国产| 欧美 日韩 成人| 91成人破解版| 三级黄色片网站| 成人在线一级片| 午夜免费福利影院| 99久久综合网| 久久久久成人精品无码中文字幕| 欧美一级片在线视频| 国产又粗又猛又爽又黄的视频四季| 中出视频在线观看| 国产精品伦子伦| 久久丫精品国产亚洲av不卡| 四季av综合网站| 91动漫免费网站| 超碰97av在线| 女同久久另类69精品国产| 三级在线观看免费大全| 欧美视频一区二区在线| 欧洲第一无人区观看| 午夜性福利视频| 国产福利在线导航| 99国产精品无码| 中文字幕手机在线观看| 国产又爽又黄无码无遮挡在线观看| 一区二区三区四区影院| 日韩少妇一区二区| 最近中文字幕在线mv视频在线| 免费黄在线观看| 91嫩草|国产丨精品入口| xxxxwww一片| 国产精品天天干| 亚洲成人生活片| 中文字幕人妻一区| 日本人亚洲人jjzzjjz| 天天鲁一鲁摸一摸爽一爽| 久久精品无码专区| 国产主播av在线| av网站有哪些| 紧身裙女教师波多野结衣| 好吊日免费视频| 亚洲综合视频网站| wwwwxxxx国产| 国产精品久久AV无码| 成年人看的免费视频| 日韩成人av影院| 日本黄区免费视频观看| av2014天堂网| 精品人妻人人做人人爽夜夜爽| 老头老太做爰xxx视频| 在线免费看黄色片| 午夜剧场免费在线观看| 国产成人av一区二区三区不卡| 黑人玩弄人妻一区二区三区| 99久久99久久精品国产| 永久免费看mv网站入口78| 中文字幕99页| 中文字幕第10页| 久久久久久久久久97| 99精品一区二区三区无码吞精| 无码h肉动漫在线观看| 中文字幕第九页| 久久久久久久久毛片| 色欲一区二区三区精品a片| 亚洲午夜久久久久久久国产| av2014天堂网| 日本黄色网址大全| xxxx黄色片| 在线天堂www在线国语对白| 人妻换人妻仑乱| 中文在线永久免费观看| 国产女人被狂躁到高潮小说| 国产毛片欧美毛片久久久| 在线观看福利片| 黄色三级生活片| 亚洲人与黑人屁股眼交| 日本爱爱小视频| 俄罗斯女人裸体性做爰| 中文字幕一二三| 完美搭档在线观看| 成人性生活免费看| 丝袜美腿中文字幕| 午夜精品久久久久99蜜桃最新版| 欧美人妻一区二区三区| 亚欧精品视频一区二区三区| 人妻无码一区二区三区免费| 人妻熟人中文字幕一区二区| 精品无码在线观看| 精品国产视频一区二区三区| 久久久久久久久久网站| 国产艳妇疯狂做爰视频| 国产精品一区二区无码对白| 久久亚洲AV成人无码国产野外| 国产jizz18女人高潮| www.四虎在线| 国产又粗又长免费视频| 国产波霸爆乳一区二区| 国产精品第七页| 欧美a在线播放| 极品白嫩少妇无套内谢| 欧美一区二区三区成人精品| 中国美女黄色一级片| 女人扒开腿免费视频app| 99re久久精品国产| 青青操在线视频观看| 色天使在线视频| 999精品在线视频| 内射中出日韩无国产剧情| 欧美一级特黄高清视频| 日本一卡二卡在线| 欧洲美女女同性互添| 强迫凌虐淫辱の牝奴在线观看| 免费一级做a爰片久久毛片潮| 丁香花五月激情| 一区二区三区在线观看免费视频| 最新中文字幕日本| 免费成人深夜天涯网站| 中文字幕天堂av| 澳门黄色一级片| 可以免费看av的网址| 久久国产精品影院| 亚洲香蕉中文网| 亚洲最大视频网| 无码人妻一区二区三区一| 破处女黄色一级片| 国产三级精品三级观看| 好吊视频在线观看| 丰满岳乱妇一区二区| 台湾佬美性中文| 日韩黄色一区二区| 国产男女无遮挡猛进猛出| 日韩av片在线| 亚洲av网址在线| 美女扒开腿免费视频| 美女又爽又黄免费| 亚洲av成人片色在线观看高潮 | 日本一区二区视频在线播放| 国产性生活毛片| 亚洲美女高潮久久久| 精品国产aⅴ一区二区三区东京热| 国产1区2区3区4区| 老女人性生活视频| 91精品国产高清91久久久久久| 国产精品精品软件男同| 天天鲁一鲁摸一摸爽一爽| 最新一区二区三区| avtt天堂在线| 国产毛片毛片毛片毛片毛片毛片| 7788色淫网站小说| 摸摸摸bbb毛毛毛片| 精品无码一区二区三区蜜臀| 婷婷伊人五月天| 国产精品入口麻豆| 中文幕无线码中文字蜜桃| 久久久久久久久免费看无码 | 人妻巨大乳一二三区| 杨幂一区二区国产精品| 亚洲麻豆一区二区三区| 少妇人妻好深好紧精品无码| 大地资源高清在线视频观看| 麻豆精品国产传媒| 性久久久久久久久久| 天堂网av2018| 深田咏美中文字幕| 亚洲一二三四视频| 国产精品扒开腿做爽爽爽a片唱戏 亚洲av成人精品一区二区三区 | 在线xxxxx| 成人午夜福利一区二区| 免费在线观看a视频| 欧美激情图片小说| 三级男人添奶爽爽爽视频| 国产高清视频免费在线观看| 国产成人av片| 国产手机在线观看| 特种兵之深入敌后| 男人的天堂av网| 免费的av网站| 国产女人被狂躁到高潮小说| 免费毛片视频网站| 麻豆精品国产传媒| 国产精品1区2区3区4区| 免费的av网站| 麻豆tv在线观看| 性欧美疯狂猛交69hd| 在线国产视频一区| 亚洲一区二区三区四区五区六区 |