Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

You can look at the Java programs in the text book to see how comments are added to programs.Skills to be Applied

CSE 205Assignment #8
Minimal Submitted Files
You are

required, but not limited, to turn in the following source files:

Assignment8.java(More code need to be added)

          ***ASSIGNMENT8.JAVA IS INCLUDED AT THE BOTTOM***

Project.java(given by the instructor, it needs to be modified for this assignment)

          ***PROJECT.JAVA IS INCLUDED AT THE BOTTOM***

Budget.java(given by the instructor, it needs to be modified for this assignment)

          ***BUDGET.JAVA IS INCLUDED AT THE BOTTOM***

ProjNumberComparator.java 
ProjNameComparator.java 
Sorts.java 
ProjectManagement.javaRequirements to get full credits in Documentation

  1. The assignment number, your name, StudentID, Lecture number/time, and a class description need to be included at the top of each file/class.
  2. A description of each method is also needed.
  3. Some additional comments inside of methods(especially for the “main” method) to explain code that are hard to follow should be written.

You can look at the Java programs in the text book to see how comments are added to programs.Skills to be Applied

In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:

Vector/ArrayList 
Sorting 
Searching 
Aggregate Objects 
Interfaces 
Serialization 
File read/writeProgram Description

Class Diagram:

         ***CLASS DIAGRAM IS ATTACHED AT THE BOTTOM***

Project

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

Budget

The Budget class implements the “Serializable” interface so 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 the both project names are same, their locations should be compared. If they have same project name and location, 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 class implements the Serializable interface. 
It has the following attributes:

projectListArrayList or VectorA list of Project objects in the project management system

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

ProjectManagement()A Constructor of the ProjectManagement class. The ArrayLists/Vectors of projectList is instantiated.
int projNumberExists(int projNumber)Search for a Project object by projNumber and return the index of the object if found. Return -1 if not found. The parameter is the projNumber of a Project object.
int nameLocationExists(String name, String location)Search for a Project object by name and location and return the index of the object if found. Return -1 if not found. The parameters are name and location of a Project object.
boolean addProject(String name, String location, int projNumber, double initialFund)Add a Project object to the project list. Return true if such object was added successfully. Return false if an object with the same projNumber already exists (the new object is not added).
boolean removeProjNumber(int projNumber)Remove a Project object from the Project list. Return true if the object was removed successfully. Return false if the object with the given projNumber does not exist.
boolean removeNameLocation(String name, String location)Remove a Project object from the Project list. Return true if the object was removed successfully. Return false if the object with the given name and location does not exist.
void sortByProjNumber()Sort the list of Project objects by projNumber. This method calls the sort method defined in the Sorts class, using an object of ProjNumberComparator class as its second parameter.
void sortByNameLocation()Sort the list of Project objects by names and locations. This method calls the sort method defined in the Sorts class, using an object of ProjNameComparator class as its second parameter.
String listProjects()List all Project objects in the projNumber list. The returned string is the concatenation of each Project object information in the list. Hint: you can utilize Project’s toString method to help you complete this method. If there is no object in the list, This method should return the string containing “nno projectnn”.
void closeProjectManagement()Closes the project management system by making the list empty. This can be done by using clear() method of the ArrayList.

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:

ChoicettActionn
——tt——n
AttAdd Projectn
DttSearch for ProjNumbern
EttSearch for Name and Locationn
LttList Projectsn
OttSort by ProjNumbern
PttSort by Name and Locationn
QttQuitn
RttRemove by ProjNumbern
SttRemove by Name and Locationn
TttClose ProjectManagementn
UttWrite Text to Filen
VttRead Text from Filen
WttSerialize ProjectManagement to Filen
XttDeserialize ProjectManagement from Filen
?ttDisplay Helpnn

Next, the following prompt should be displayed:

What action would you like to perform?n

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:n

Read in project name and prompt:

Please enter its location to add:n

Read in location name and prompt:

Please enter its projNumber to add:n

Read in projNumber name and prompt:

Please enter its initial budget to add:n

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 addedn

Otherwise, display:

project existsn

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

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

Search by ProjNumber

Your program should display the following prompt:

“Please enter projNumber to search:n

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 foundn

Otherwise, display this:

projNumber not foundn

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

Please enter an integer for projNumber. Project not foundn

Search by Name and Location

Your program should display the following prompt:

Please enter a name to search:n

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

Please enter a location to search:n

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 foundn

Otherwise, display this:

project name and location not foundn

Sort By ProjNumber

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

sorted by projNumbern

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 locationsn

Remove By ProjNumber

Your program should display the following prompt:

Please enter projNumber to remove:n

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 removedn

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

projNumber not foundn

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

Please enter an integer for projNumber. Project not removedn

Remove By Name and Location

Your program should display the following prompt:

Please enter a name to remove:n

Read in the project name and display the following prompt:

Please enter a location to remove:n

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 removedn

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

name and location not foundn

List Projects

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

nProject Name:ttConstruction Projectn 
Project Number:tt15n 
Project Location:tPhoenixn 
Budget:n
Initial Fundingt$0.00n
Spendingt$0.00n
Current Balancet$0.00nn

 

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

nno projectnn

Close ProjectManagement

Delete all Project objects. Then, display the following:

project management system closedn

Write Text to File

Your program should display the following prompt:

Please enter a file name to write:n

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:n

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

If the operation is successful, display the following:

FILENAME was writtenn

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:n

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 readn

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

The first line of the file is:n

CONTENTn

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 foundn

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:n

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 writtenn

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:n

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 readn

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.Test cases:Input

The following files are the test cases that will be used as input for your program (Right-click and use “Save As”):

Test Case #1:

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"