[Solved] CSE205 Assignment #4

$25

File Name: CSE205_Assignment_#4.zip
File Size: 188.4 KB

SKU: [Solved] CSE205 Assignment #4 Category: Tag:
5/5 - (1 vote)

Minimal Submitted Files

You are required, but not limited, to turn in the following source file:

Assignment4.java (Download this file and use it as your driver program for this assignment)

Assignment4.java

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:

ClassesInstance ObjectsAccessors/Mutators(Modifiers) methodsVisibility Modifiers (Access specifier) public, private, etc.Encapsulation conceptAggregation relationship between classes

Program Description

Class Diagram:

hw4ClassDiagram.jpg

Assignment #4 will be the construction of 2 new classes and a driver program (the class containing a 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:


Club Name:ttSwimming Club
Number Of Members:t87
University:ttArizona State University
President:ttWater,Bob(Senior)

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,

Assignment4.java

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:

ChoicettAction
tt
AttAdd Club
DttDisplay Club
QttQuit
?ttDisplay Help

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, re-display 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::nEnter its name:

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


Club Name:ttSwimming Club
Number Of Members:t87
University:ttArizona State University
President:ttWater,Bob(Senior)

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

Test Cases

Download the following input files, input1.txt, input2.txt, input3.txt, and input4.txt, and the following output files, output1.txt, output2.txt, output3.txt, and output4, and save them in the same directory as Assignment4.java is located.

input1.txt

input2.txt

input3.txt

input4.txt

output1.txt

output2.txt

output3.txt

output4.txt

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 on 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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE205 Assignment #4
$25