Ass05

docx

School

Wayne State University *

*We aren’t endorsed by this school

Course

3020

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

6

Uploaded by MateMandrill3698

Report
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM gAll assignments must be submitted by the Canvas. No email or hard copy is accepted. Submit your file to the Canvas. You must submit your assignment on time; otherwise, you will receive zero. In addition, you cannot submit your file more than one time . 1. You need to upload your file(s) using the correct folder on the Canvas. 2. Name each file: “ AccessID _Assignment5.docx Your .docx Format must be formatted as follows: o Use Header 1 Titled Code o User Header 2 Titled Class List your Class code Don’t just paste…insert page breaks as necessary. o User Header 2 Titled Main List your Main code. Don’t just paste…insert page breaks as necessary. o User Header 1 Titled Scenarios o User Header 2 Titled Scenario 1 Scenario Description Scenario Picture (readable!!!). o User Header 2 Titled Scenario 2 o User Header 2 Titled Scenario N It is your responsibility to make sure that each file is uploaded correctly. If you uploaded a wrong file, you receive zero; files will not be accepted after due date even if you have a prove that the file is created before the due date. Your program should be free of syntax errors (i.e. it must compile). If it does not, you will receive a zero. Solution to this assignment will not be posted on Canvas; however, any question can be discussed in the class upon request of a student. Each solution text file MUST have the following flower box comment along with labels. /******************************************************************** Name: Access ID: Date: mm/dd/yyyy
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM *******************************************************************/
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM Write a java program that uses a rectangle class to take user input (50 pts). Coding Style You must use appropriate variable names that are descriptive of the variable contents, method function, etc. You must use single-letter variables for for loops. You must name variables, method names, and classes using standards presented in class (i.e. camel case, or init capped). You must use a Class Object to perform calculations. The main loop drives the menu options. You must use class methods to perform menu items. When prompting for data, make sure there are no errors in response. Respond appropriately and then re prompt. Each method MUST have a flower pot comment which also includes a description of what the method does. This will be placed BEFORE the actual method declaration. /************************************************************************ Method Name : Method Description : <what does this method do.> <what’s special about this method (i.e. is it overloaded?, any assumptions ) Method Input Parameters : <param 1> what it contains. <param 2> what it contains. If no parameters, say that instead. Method Return Parameters <param 1> what is sent back Author Name: Author Access ID: Author Date: *************************************************************************/
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM Ship Classes (50 Points) a. (5 points) Design a Ship class that the following members: A field for the name of the ship (a string) A field for the year that the ship was built (a string) A constructor and appropriate accessors and mutators A toString method that displays the ship’s name and the year it was built b. (5 points) Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int ) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display the ship’s name, year, and the maximum number of passengers. c. (5 points) Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the ship capacity in tonnage (an int ) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class. The CargoShip class’s toString method should display the ship’s name, year, and the ship’s capacity. d. (5 points) Design a TankerShip class that extends the Ship class. The TankerShip class should have the following members: A field for type of liquid or gas in bulk (a String) and a field for capacity in tonnage (a double). A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class. The TankerShip class’s toString method should display the ship’s name, year, type of liquid, and capacity. e. (20 points) Override method compareTo in CruiseShip (compare by number of passengers), class CargoShip (compare by capacity), and TankerShip (compare by type of liquid). f. (5 points) Demonstrate the classes in a program ( ShipDemo class ) that has a Ship arrayList. Assign various CruiseShip, CargoShip, and TankerShip objects to the array elements. The program should then step through the array, calling each object’s toString method. g. (5 points) Create three objects of CruiseShip class and store them in an array; sort the array; print all objects before and after you sort them. 2 points will be deducted for not including comments.
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM Sample Output - Console Window Name: Disney Magic Year: 1998 Maximum passengers: 2400 ---------------------------- Name: Black Pearl Year: 1800 Cargo capacity: 50000 tons ---------------------------- Name: Lolipop Year: 1960 Type: Oil Capacity: 500000.0 ---------------------------- Before sorting three objects of CruiseShip: [1] Name: Disney Magic1 Year: 1998 Maximum passengers: 2400 [2] Name: Disney Magic2 Year: 2002 Maximum passengers: 2500 [3] Name: Disney Magic3 Year: 2011 Maximum passengers: 400 After sorting three objects of CruiseShip: [1] Name: Disney Magic2 Year: 2002 Maximum passengers: 2500 [2] Name: Disney Magic1 Year: 1998 Maximum passengers: 2400 [3] Name: Disney Magic3 Year: 2011 Maximum passengers: 400 Process finished with exit code 0 Please keep these points in mind: 3 points will be deducted for not including comments. 2 points will be deducted for not having at least 3 Cruise examples. 2 points will be deducted for not making a reasonable attempt to match output.
CSC 3020 Java Programming Assignment 5 50 points Due 11/13/2023 11:59 PM I only show output here. You should include prompting for data just like we’ve been doing all along. You should have an appropriate welcome and goodbye message. These should be private variables in the main cruise class. Don’t forget the accessors / mutators. There should be at least 3 scenarios: Perfect Example of entering and outputting requested data for 2 cruises. Examples of entering incorrect data and prompting for a correct value. Examples of sorting the array. Show before sort, and after sort. No tostrings -> -3 No toCompare -> -5 No checking input -> -3 No Good private declaration of variables (i.e. _variableName) -2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help