$30
CSE205 -Assignment #4
Make sure that you write every line of your code. Using code written by someone else will be considered a violation of the academic integrity and will result in a report to the Dean's office.
It must be submitted on GradeScope, The link is provided on the Course website
Minimal Submitted Files
You are required, but not limited, to turn in the following source file:
Assignment4.java (https://canvas.asu.edu/courses/44324/files/12113787/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113787/download?wrap=1) (Download this file and use it as your driver program for this assignment)
Club.java
President.java
Requirements to get full credits in Documentation
The assignment number, your name, StudentID, Lecture day/time, and a class description need to be included at the top of each file/class.
A description of each method is also needed. Some additional comments inside of methods (especially for a "main" method) to explain code that are hard to follow should be written.
New 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:
Classes
Instance Objects
Accessors/Mutators(Modifiers) methods
Visibility Modifiers (Access specifier) - public, private, etc.
Encapsulation concept
Aggregation relationship between classes
Program Description
Class Diagram: hw4ClassDiagram.jpg (https://canvas.asu.edu/courses/44324/files/12113785/download?wrap=1)
Assignment #4 will be the construction of 2 new classes and a driver program (the class containing the main method).
President class
The President class describes information of a president of a club. It has following attributes:
Attribute name
Attribute type
Description
firstName
String
The first name of the president
lastName
String
The last name of the president
academicLevel
String
The academic level of the president such as senior, junior, etc.
The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?". public President( )
The following accessor methods should be provided to get the attributes:
public String getFirstName() public String getLastName() public String getAcademicLevel()
The following modifier(mutator) methods should be provided to set the attributes:
public void setFirstName(String someFirstName) public void setLastName(String someLastName) public void setAcademicLevel(String someLevel)
The following method must be defined:
public String toString() toString method should return a string of the following format:
Water,Bob(Senior) where "Water" is the last name of a president, "Bob" is the first name, and "Senior" is the academic level.
So you need to insert "," or parentheses between these variables.
Note that you can choose a meaningful parameter variable name for each method.
Club class
The Club class describes a club. It has the following attributes:
Attribute name
Attribute type
Description
clubName
String
The name of the Club.
numberOfMembers
int
The number of members of the club
university
String
The university of the club
currentPresident
President
The current president of the club
The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?" and the value of integer attribute to 0,
and an object of President using the constructor of the President class.
public Club( )
The following accessor methods should be provided to get the attributes:
public String getClubName() public int getNumberOfMembers() public String getUniversity() public President getCurrentPresident()
The following modifier(mutator) methods should be provided to change the attributes:
public void setClubName(String someName) public void setNumberOfMembers(int someNumber) public void setUniversity(String someUniversity)
public void setCurrentPresident(String firstName, String lastName, String someLevel)
The following method must be defined:
public String toString()
The toString() method constructs a string of the following format:
\nClub Name :\t\tSwimming Club\n
Number Of Members:\t87\n
University:\t\tArizona State University\n
President:\t\tWater,Bob(Senior) \n\n
Assignment4
(Note that this part is already done in the Assignment4.java file that is given to you. This explains each functionality of this class.)
In this assignment, download Assignment4.java file, and use it for your assignment. You do not need to modify Assignment4.java file. You only need to write Club.java and President.java files.
The following is the description of Assignment4 class.
The driver program will allow the user to interact with your other class modules. The purpose of this module is to handle all user input and screen output. The main method should start by displaying the following menu in this exact format:
Choice\t\tAction\n
------\t\t------\n
A\t\tAdd Club\n
D\t\tDisplay Club\n
Q\t\tQuit\n
?\t\tDisplay Help\n\n
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.
Add Club
Your program should display the following prompt:
Please enter the Club information::\n
Enter its name:\n
Read in the user input and set the club name on the club object. Then it will ask a user to enter its number of members, its university, its president's first name, last name, and academic level.
Read in the user input and set them on the club object.
Note that there is only one Club object in this assignment. Thus when "Add Club" option is selected more than once, the new one overwrites the old Club object information.
Display Club
Your program should display the club information in the following format:
\nClub Name :\t\tSwimming Club\n
Number Of Members:\t87\n
University:\t\tArizona State University\n
President:\t\tWater,Bob(Senior) \n\n
Make use of the toString method of the Club class to display this information. The toString method is used together with System.out.print method.
(System.out should NOT to be used within the toString method.)
Quit
Your program should stop executing and output nothing.
Display Help
Your program should redisplay the "choice action" menu.
Invalid Command
If an invalid command is entered, display the following line:
Unknown action\n
Test Cases
Download the following input files and the following output files, and save them in the same directory as Assignment4.java is located.
input1.txt (https://canvas.asu.edu/courses/44324/files/12113775/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113775/download?wrap=1)
input2.txt (https://canvas.asu.edu/courses/44324/files/12113776/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113776/download?wrap=1)
input3.txt (https://canvas.asu.edu/courses/44324/files/12113777/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113777/download?wrap=1)
input4.txt (https://canvas.asu.edu/courses/44324/files/12113778/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113778/download?wrap=1)
output1.txt (https://canvas.asu.edu/courses/44324/files/12113779/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113779/download?wrap=1)
output2.txt (https://canvas.asu.edu/courses/44324/files/12113781/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113781/download?wrap=1)
output3.txt (https://canvas.asu.edu/courses/44324/files/12113782/download?wrap=1)
(https://canvas.asu.edu/courses/44324/files/12113782/download?wrap=1)
output4.txt (https://canvas.asu.edu/courses/44324/files/12113783/download?wrap=1) (https://canvas.asu.edu/courses/44324/files/12113783/download?wrap=1)
Error Handling
Your program should be robust enough to handle all test cases above.
--------------------------------------------
What to turn in:
-Submit your Assignment4.java, Club.java, and President.java files using Gradescope- Assignment4 from canvas.asu.edu. Make sure that it is passing all test cases. Otherwise you will lose points for test cases (8pts). You can submit multiple times until the assignment deadline.
Grading Criteria:
____/ 5 Documentation (Each file needs to have a header with your name, your information, and program description, each method needs its description and comments within your code)
____/ 1 Indentation and spacing (easy to read)
____/ 6 Required classes/methods and functionalities implemented
____/ 8 Produces correct results (test cases – auto graded)?
Total points: 20