Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

how to code someting for this assignment *the given code and test cases are at t

ID: 3678947 • Letter: H

Question

how to code someting for this assignment *the given code and test cases are at the bottom*

Program Description

Class Diagram:

Project

The Project class implements the "Serializable" interfaceso that its object can be stored. (The Serializable interface is defined in the "java.io" package.)

Budget

The Budget class implements the "Serializable" interfaceso that its object can be stored. (The Serializable interface is defined in the "java.io" package.)

ProjNumberComparator

The ProjNumberComparator class implements the "Comparator" interface (The Comparator interface is in "java.util" package.). It needs to define the following method that was an inherited abstract method from Comparator interface:

public int compare(Object first, Object second)

(Note that you can also define:
public int compare(Project first, Project second)
instead by making the class implements Comparator<Project>.

If the first argument object has a smaller projNumber than that of the second argument, an int less than zero is returned. If the first argument object has a larger projNumber than that of the second argument, an int greater than zero is returned. If the both are same, 0 should be returned.

The Budget class also implements the "Serializable" interface so that its object can be stored.

ProjNameComparator

The ProjNameComparator class implements the "Comparator" interface (The Comparator interface is in "java.util" package.). It needs to define the following method that was an inherited abstract method from Comparator interface:

public int compare(Object first, Object second)

(Note that you can also define:
public int compare(Project first, Project second)
instead by making the class implements Comparator<Project>.

If the first argument object has a project name lexicographically less than that of the second argument, an int less than zero is returned. If the first argument object has a project name lexicographically larger than that of the second argument, an int greater than zero is returned. If their locations are same, then their project names should be compared. If they have same location and project name, then 0 should be returned.

Sorts

The Sorts class is a utility class that will be used to sort a list of Project objects. Sorting algorithms are described in the algorithm note posted under Notes section of the course web site. These algorithms sort numbers stored in an array. It is your job to modify it to sort objects stored in an array list (or a vector).
The Sorts class object will never be instantiated. It must have the following methods:

public static void sort(ArrayList objects, Comparator<Project>)

Your sort method utilizes the compare method of the parameter Comparator object to sort. You can use one of Selection sort or Insertion Sort.

ProjectManagement

The ProjectManagement class has a list of Project objects that can be organized at the project management system. The project management system will be a fully encapsulated object. The ProjectManagement classimplements the Serializable interface.
It has the following attributes:

The following public methods should be provided to interact with the project management system:

No input/output should occur in the project management system. User interaction should be handled only by the driver class.

You may add other methods to the class in order to make your life easier.

Assignment8

All input and output should be handled in Assignment8 class. The main method should start by displaying this updated menu in this exact format:

Choice Action
------ ------
A Add Project
D Search for ProjNumber
E Search for Name and Location
L List Projects
O Sort by ProjNumber
P Sort by Name and Location
Q Quit
R Remove by ProjNumber
S Remove by Name and Location
T Close ProjectManagement
U Write Text to File
V Read Text from File
W Serialize ProjectManagement to File
X Deserialize ProjectManagement from File
? Display Help

Next, the following prompt should be displayed:

What action would you like to perform?

Read in the user input and execute the appropriate command. After the execution of each command, redisplay the prompt. Commands should be accepted in both lowercase and uppercase. The following commands are modified or new.

Add Project

Your program should display the following prompt:

Please enter a project name to add:

Read in project name and prompt:

Please enter its location to add:

Read in location name and prompt:

Please enter its projNumber to add:

Read in projNumber name and prompt:

Please enter its initial budget to add:

Read in budget, and if the Project object with the projNumber is not in the project list, then add it into the project list and display:

project added

Otherwise, display:

project exists

Also, if projNumber entered is not an integer, display:

Please enter a numeric value for project number and budget. Project not added

Search by ProjNumber

Your program should display the following prompt:

"Please enter projNumber to search:

Read in the projNumber and look up the project list, if there exists a Project object with the same projNumber, then display the following:

projNumber found

Otherwise, display this:

projNumber not found

Also, if projNumber entered is not an integer, display:

Please enter an integer for projNumber. Project not found

Search by Name and Location

Your program should display the following prompt:

Please enter a name to search:

Read in the project name, then display the following prompt:

Please enter a location to search:

Read in the location, and search the project list based on these information. If there exists a Project object with the name and the location, then display the following:

project name and location found

Otherwise, display this:

project name and location not found

Sort By ProjNumber

Your program should sort the project list using projNumber in their increasing order and output the following:

sorted by projNumber

Sort By Name and Location

Your program should sort the project list using locations and project names in alphabetical order by comparing locations first, and if they are same, comparing names and output the following:

sorted by project names and locations

Remove By ProjNumber

Your program should display the following prompt:

Please enter projNumber to remove:

Read in the integer. If the Project object can be found in the project list, then remove it from the list, and display the following:

projNumber removed

If there is no such Project object in the project list, display:

projNumber not found

Also, if projNumber entered is not an integer, display:

Please enter an integer for projNumber. Project not removed

Remove By Name and Location

Your program should display the following prompt:

Please enter a name to remove:

Read in the project name and display the following prompt:

Please enter a location to remove:

Read in the location. If the Project object can be found in the project list, then remove it from the list, and display the following:

name and location removed

If there is no such Project object in the project list, display:

name and location not found

List Projects

Each Project object information in the project list should be displayed in the following format:

Project Name: Construction Project
Project Number: 15
Project Location: Phoenix
Budget:
Initial Funding $0.00
Spending $0.00
Current Balance $0.00

If there is no Project object in the project list, display:

no project

Close ProjectManagement

Delete all Project objects. Then, display the following:

project management system closed

Write Text to File

Your program should display the following prompt:

Please enter a file name to write:

Read in the filename and create an appropriate object to get ready to read from the file. Then it should display the following prompts:

Please enter a string to write in the file:

Read in the string that a user types, say "input", then attach " " at the end of the string, and write it to the file. (i.e. input+" " string will be written in the file.)

If the operation is successful, display the following:

FILENAME was written

Replace FILENAME with the actual name of the file.

Use try and catch statements to catch IOException. The file should be closed in a finally statement.

Read Text from File

Your program should display the following prompt:

Please enter a file name to read:

Read in the file name create appropriate objects to get ready to read from the file. If the operation is successful, display the following (replace FILENAME with the actual name of the file):

FILENAME was read

Then read only the first line in the file, and display:

The first line of the file is:

CONTENT

where CONTENT should be replaced by the actual first line in the file.

Your program should catch the exceptions if there are. (Use try and catch statement to catch, FileNotFoundException, and the rest of IOException.)

If the file name cannot be found, display

FILENAME was not found

where FILENAME is replaced by the actual file name.

Serialize ProjectManagement to File

Your program should display the following prompt:

Please enter a file name to write:

Read in the filename and write the serialized ProjectManagement object out to it. Note that any objects to be stored must implement Serializable interface. The Serializable interface is defined in java.io.* package. If the operation is successful, display the following:

FILENAME was written

Replace FILENAME with the actual name of the file.

Use try and catch statements to catch NotSerializableExeption and IOException.

Deserialize ProjectManagement from File

Your program should display the following prompt:

Please enter a file name to read:

Read in the file name and attempt to load the ProjectManagement object from that file. Note that there is only one ProjectManagement object in the Assignment8 class, and the first object read from the file should be assigned to the ProjectManagement object. If the operation is successful, display the following (replace FILENAME with the actual name of the file):

FILENAME was read

Your program should catch the exceptions if there are.

(Use try and catch statement to catch ClassNotFoundException, FileNotFoundException, and the rest of IOException.)

See the output files for exception handling.

Assignment8.java

Project.java

Budget.java

TEST CASE INPUTS #1

expected OUTPUT

Attribute name Attribute type Description projectList ArrayList or Vector A list of Project objects in the project management system

Explanation / Answer

yes this code is fine . all test cases will work with junit.