Question
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.
- Create a Passenger class and be sure to followthis UMLDownload this UMLexactly
- Create a Train class and besure to followthis UMLDownload this UMLexactly
- 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.
- Make the following changes to Program5Trains.Note that you must make these changes in order!!!!
- Modify the Passenger named Harry to Harry Truman.
- 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.
- Modify line 30 ONLY to append a tab and "on board!" to each passenger.
- Add a new line 45 that adds a new passenger named Doctor Suess who is not traveling first class to link.
- Add a new line 19 that creates a NumberFormat for percentages
- Add a new line 19 that creates a NumberFormat for currency
- 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.
- 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
-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 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started