Create an application named travelcosts

Assignment Help JAVA Programming
Reference no: EM131604780

Create an application named TravelCosts that is made up of a number of different classes.

Create an abstract superclass called Transportation that has the following three fields:
protected String routeName;
protected int distanceInMiles;
protected int passengerCapacity;
Your class must have a three argument constructor that initializes those three fields, and the class must also have the following getters and setters for those fields:
public String getRouteName()
public void setRouteName(String name)
public int getDistanceInMiles()
public void setDistanceInMiles(int distance)
public int getPassengerCapacity()
public void setPassengerCapacity(int capacity)
The setters for the distanceInMiles and the passengerCapacity must protect that data from getting negative values.
The Transportation class also has an abstract method called getFare() that takes no arguments and returns a double which represents the cost of the trip. Also create a toString() method that returns a String with the route name followed by the distance of the trip followed by the passenger capacity. All of this data must have proper labels and it must be on three separate lines.

Next create two child classes of the Transportation class called TaxiTrip and TrainTrip.

The TaxiTrip class has the following additional field:
protected double ratePerMile;
Create a four argument constructor for this class that sets this field as well as the fields of the superclass. Be sure to set the superclass fields with a call to super(), and remember that when you use a super() call it must be the first line of the constructor.
Also create a getter and a setter method for this field, and be sure the setter method protects the field from getting negative values.
For the TaxiTrip class you need to override the getFare() method such that it determines the fare by multiplying the distanceInMiles with the ratePerMile.
And you must create a toString() method that returns a String with the parent information using a call to super.toString() and then on a separate lineshow the cost of the trip formatted as a dollar amount to two decimals and include a proper label for that information.

The TrainTrip class has the following additional field:
protected int stopsInRoute;
Create a four argument constructor for this class that sets this field as well as the fields of the superclass. Be sure to set the superclass fields with a call to super(), and remember that when you use a super() call it must be the first line of the constructor.
Also create a getter and a setter method for this field, and be sure the setter method protects the field from getting negative values.
For the TrainTrip class you need to override the getFare() method such that the cost of a trip is determined by how far the trip is as well as by how many stops there are on the route. There is a base fare for the trip which is the value of 1/10th of the distance of the trip in dollars and cents. So, for example, if the trip is going to be 555 miles, then the cost will be 1/10th of that, or $55.50. However, the company wants to compensate passengers for too many stops on the route, and so the company subtracts 1/10th of the base fare for the first stop, and 1/100th of the base fare for the second stop, and so on, subtracting 1/10nth of the base fare for every nth stop. If there are no stops, then nothing is subtracted.
For example, if there are 3 stops for a 1000 mile trip, then the base fare is $100.00 and the total fare is:
Total Fare = $100.00 - (100.00 * 1/10) - (100.00 * 1/100) - (100.00 * 1/1000)
Total Fare = $100.00 - 10.00 - 1.00 - 0.10
Total Fare = $88.90
And you must create a toString() method that returns a String with the parent information using a call to super.toString() and then on a separate lineshow the cost of the trip formatted as a dollar amount to two decimals and include a proper label for that information.

Write a driver program called MakeTrip that has the main() method and that test the TaxiTrip and TrainTrip by creating two different Taxi trips and two different Train Trips and then prints them out.

Reference no: EM131604780

Questions Cloud

What is your key performance indicator : What is your key performance indicator (KPI)? For instance, how many views will you earn in a set period of time? What is your content marketing strategy?
The psychological theories of crime : Which type of justice is most useful based on the psychological theories of crime? For which types of crimes and offenders is it most useful?
Review case study of open-topped rectangular box : A open-topped rectangular box, with a square base x by x cm and height h cm.
Find the dimensions of the solid giving the maximum volume : Find the dimensions of the solid giving the maximum volume, given that the surface area is 8 cm2. A closed rectangular box, with a square base x by x cm.
Create an application named travelcosts : Create an application named TravelCosts that is made up of a number of different classes - Create a four argument constructor for this class
What is the current design of your job : What is the current design of your job? Assume that the opportunity arose for you to utilize the idiosyncratic deals (i-deals) in redesigning your job.
Identify each critical point as a local maximum : Find values of the parameters a and b so that f has a critical point at the point (5, 12).
Writing a program that computes the salaries : Writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes.
Discuss the effectiveness of criminal justice research : What are some examples of the effectiveness of criminal justice research in finding solutions to problems

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd