Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new Java project named Program 5 Trains. In this project, create a package named trainsDemo and put all 3 of the classes discussed

Create a new Java project named Program 5 Trains. In this project, create a package named trainsDemo and put all 3 of the classes discussed below in this package

Include a header comment to EACH OF your files, as indicated in your instructions. Here's alinkDownload linkdescribing the header. Note that headers are not meant to be in Javadoc format.

Note that Javadoc IS required for this assignment. Remember to Javadoc all classes, fields, constructors, and methods.

  1. Create a Passenger class and be sure to followthis UMLDownload this UMLexactly
  2. Create a Train class and besure to followthis UMLDownload this UMLexactly
  3. Create a third class named Program5Trains. Overwrite the code in Program5Trains with a copy ofthisDownload thiscode into it... if it does not compile, you misnamed something. Make sure that all of your classes and members are named correctly, and make sure your package is named correctly. When run, it should matchthis text file'sDownload this text file'soutput EXACTLY. If it does not, modify your classes until it does.
  4. Make the following changes to Program5Trains.Note that you must make these changes in order!!!!
    1. Modify the Passenger named Harry to Harry Truman.
    2. Add a new Passenger to passengers named "A new passenger" who is traveling first class. Add only one line (a new line 24) and modify one line.
    3. Modify line 30 ONLY to append a tab and "on board!" to each passenger.
    4. Add a new line 45 that adds a new passenger named Doctor Suess who is not traveling first class to link.
    5. Add a new line 19 that creates a NumberFormat for percentages
    6. Add a new line 19 that creates a NumberFormat for currency
    7. Modify lines 53 and 54 to use the NumberFormats you created appropriately. This will make these lines excessively long, so continue on a new line for both of them.
    8. Replace line 59 (System.out.println("Bob Marley is "+(zelda.isPassengerOnTrain("Bob Marley")?"":"not ")+"on Zelda 550");) with code that does not use the ternary if (ie, the ? and :) but produces the same output. Use as many lines as are necessary.

Your Program5Trains.java, Train.java, and Passenger.java files.

From Note that Javadoc IS required for this assignment links. I couldn't added link so I put the pictures of those links.

1. this UML

imageimageimageimage

-name: String UML for Passenger Passenger -is FirstClass: boolean + < >Passenger(name: String, is FirstClass: boolean) +getName(): String +setName(name: String): void +is FirstClass(): boolean +setFirstClass(is FirstClass: boolean): void +equals(o: Object): boolean +toString(): String Notes The constructor should initialize all variables equals should compare the two objects' to String() Note that is FirstClass() is a slightly different name than the standard getter. Note that setFirstClass() is a slightly different name than a standard setter. toString() should return a String in the following format: [Name]: ! or [Name] - (note: for first class there is a single tab between name and !) (note: for non-first class) Example of Dave in first class: Dave: ! Example of Dave not in first class Dave

Step by Step Solution

There are 3 Steps involved in it

Step: 1

I can provide you with the code for the classes and the modified Program5Trains class as requested Please create the files yourself and copy the code into them Here is the code for the Passenger class ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions