Write a test code for this class in a same file called CarTest
Write the test code in main function
public class Car {
public String brandName;
public String modelName;
public int year;
public int maxSpeed;
public Car(String string, String string2, int n) {
this.brandName = string;
this.modelName = string2;
this.year = n;
}
public Car(String string, String string2, int n, int n2) {
this.brandName = string;
this.modelName = string2;
this.year = n;
this.maxSpeed = n2;
}
public String getBrandName() {
return this.brandName;
}
public String getModelName() {
return this.modelName;
}
public int getYear() {
return this.year;
}
public boolean isFasterThan(Car car) {
return this.maxSpeed >= car.maxSpeed;
}
public void setMaxSpeed(int n) {
this.maxSpeed = n;
}
}Please find the code below:
CarTest.java
package classes6;
class Car {
public String brandName;
public String modelName;
public int year;
public int maxSpeed;
public Car(String string, String string2, int n)
{
this.brandName = string;
this.modelName = string2;
this.year = n;
}
public Car(String string, String string2, int n,
int n2) {
this.brandName = string;
this.modelName = string2;
this.year = n;
this.maxSpeed = n2;
}
public String getBrandName() {
return this.brandName;
}
public String getModelName() {
return this.modelName;
}
public int getYear() {
return this.year;
}
public boolean isFasterThan(Car car) {
return this.maxSpeed >=
car.maxSpeed;
}
public void setMaxSpeed(int n) {
this.maxSpeed = n;
}
}
public class CarTest {
public static void main(String[] args) {
Car car1 = new Car("BWM", "C12345",
1993,900);
System.out.println("Details of car1
is as below");
System.out.println("Brand Name :
"+car1.getBrandName());
System.out.println("Model Name :
"+car1.getModelName());
System.out.println("Year :
"+car1.getYear());
Car car2 = new Car("AUDI", "P0900",
1900);
car2.setMaxSpeed(800);
System.out.println(" Details of
car2 is as below");
System.out.println("Brand Name :
"+car2.getBrandName());
System.out.println("Model Name :
"+car2.getModelName());
System.out.println("Year :
"+car2.getYear());
System.out.println(" Is car1 is
faster than car 2 : "+car1.isFasterThan(car2));
System.out.println("Setting car2
speed to 1900");
car2.setMaxSpeed(1900);
System.out.println("Now is car1 is
faster than car 2 : "+car1.isFasterThan(car2));
}
}
output:

Write a test code for this class in a same file called CarTest Write the test...
Below are the Car class and Dealership class that I
created In the previous lab
import java.util.ArrayList;
class Car
{
private String make;
private String model;
private int year;
private double transmission;
private int seats;
private int maxSpeed;
private int wheels;
private String type;
public Car()
{
}
public Car(String make, String model, int year, double transmission, int seats, int maxSpeed, int wheels, String type) {
this.make = make;
this.model = model;
this.year = year;
this.transmission = transmission;
this.seats =...
public class Car { /* four private instance variables*/ private String make; private String model; private int mileage ; private int year; // /* four argument constructor for the instance variables.*/ public Car(String make) { super(); } public Car(String make, String model, int year, int mileage) { super(); this.make = make; this.model...
The code should be written in C++. I included the Class used for this function. Also, please fix the main function if necessary. Description: This function de-allocates all memory allocated to INV. This will be the last function to be called (automatically by the compiler) //before the program is exited. This function also erased all data in the data file. There are other functions that add, process and alter the file; the file printed after those functions will have new...
Can someone help me with my Java code error! Domain package challenge5race; import java.util.Random; public class Car { private int year; private String model; private String make; int speed; public Car(int year, String model, String make, int speed) { this.year = year; this.model = model; this.make = make; this.speed = speed; } public Car() { } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public String getModel() { return model; }...
Java:
Create the skeleton.
Create a new file called ‘BasicJava4.java’
Create a class in the file with the appropriate name.
public class BasicJava4 {
Add four methods to the class that return a default value.
public static boolean isAlphabetic(char aChar)
public static int round(double num)
public static boolean useSameChars(String str1, String
str2)
public static int reverse(int num)
Implement the methods.
public static boolean isAlphabetic(char aChar):
Returns true if the argument is an alphabetic character, return
false otherwise. Do NOT use...
I need to create a Java class file and a client file that does the following: Ask user to enter Today’s date in the form (month day year): 2 28 2018 Ask user to enter Birthday in the form (month day year): 11 30 1990 Output the following: The date they were born in the form (year/month/day). The day of the week they were born (Sunday – Saturday). The number of days between their birthday and today’s...
CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE. SAME CODE SHOULD BE USED FOR THE DOCUMENTATION PURPOSES. ONLY INSERT THE JAVA DOC. //Vehicle.java public class Vehicle { private String manufacturer; private int seat; private String drivetrain; private float enginesize; private float weight; //create getters for the attributes public String getmanufacturer() { return manufacturer; } public String getdrivetrain() { return drivetrain;...
In a file named LLBag.java, write a class called LLBag that implements the Bag interface using a linked list instead of an array. You may use a linked list with or without a dummy head node. Bag interface code: /* * Bag.java * * Computer Science 112, Boston University */ /* * An interface for a Bag ADT. */ public interface Bag { /* * adds the specified item to the Bag. Returns true on success * and...
Write Junit test for the following class below: public class Player { public int turnScore; public int roundScore; public int lastTurnScore; public String name; public int chipPile; public Player (String name) { this.name = name; this.turnScore = 0; this.chipPile = 50; } public int getChip() { return chipPile; } public void addChip(int chips) { chipPile...
*** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J IN CLASS (IF IT DOESNT MATTER PLEASE COMMENT TELLING WHICH PROGRAM YOU USED TO WRITE THE CODE, PREFERRED IS BLUE J!!)*** ArrayList of Objects and Input File Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info...