[Solved] CSE205 Assignment4

$25

File Name: CSE205_Assignment4.zip
File Size: 169.56 KB

SKU: [Solved] CSE205 Assignment4 Category: Tag:
5/5 - (1 vote)

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:


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, 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?

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

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

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] CSE205 Assignment4
$25