Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Please Using the Template, i need help with this project. import java.util.Scanner; public class TemplateForProjects { private final static String TITLE = CSC111

In Java Please Using the Template, i need help with this project. image text in transcribed

import java.util.Scanner;
public class TemplateForProjects {
private final static String TITLE = "CSC111 Project Template";
private final static String CONTINUE_PROMPT = "Do this again? [y/N] ";
//**********************************************
// Put as many methods you need here
//**********************************************
// Start your logic coding in the process method
private static void process(Scanner input, String args[]) throws Exception {
// Following code is merely a sample, delete it
System.out.print("Enter value: ");
int x = input.nextInt();
System.out.println("Processing " + x + " ...");
input.nextLine(); // Clear the Keyboard
}
//**********************************************
// Do not change the doThisAgain method
private static boolean doThisAgain(Scanner input, String prompt) {
System.out.print(prompt);
String doOver = input.nextLine();
return doOver.trim().equalsIgnoreCase("Y");
}
//**********************************************
// Do not change the main method
public static void main(String args[]) throws Exception {
System.out.println("Welcome to " + TITLE);
Scanner input = new Scanner(System.in);
do {
process(input, args);
} while (doThisAgain(input, CONTINUE_PROMPT));
input.close();
System.out.println("Thank you for using " + TITLE);
}
}
Write a class called Vehicle containing the following fields: - make: (i.e. Ford) - model: (i.e. Taurus) - year - speed - distance (Distance traveled in race) It should include a constructor that takes make, model, and year and initializes the proper fields with this data. Zero out the speed and distance. The methods a Vehicle should have are: - accessor (getters) - methods that return the values of these private fields. (setDistance is a bit different.) - mutators (setters) - methods that change the values of these private fields. Make sure bad data does not enter the object. - make should not be empty or null - model should not be empty or null - year >=1950 - speed >=0 - setDistance is special and is described next - setDistance () - that takes a time in minutes, calculates the distance traveled by the car based on the current speed and time input and adds it to the total distance traveled by the car. - toString() - So you can print the object properly If written correctly, your Vehicle class should work plug and play into both driver projects! Submit a gist of the Vehicle class as well as the drivers. Make sure you include the proper global header. Look at the Project Template for that header. Driver Description Sample loop: private static void raceThemCars(Vehicle car1, Vehicle car2) \{ while (car1.getDistance ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions