I need the following code to keep the current output but also include somthing similar to this but with the correct details from the code.
Truck Details:
Skoda
100
Nathan Roy
150.5
3200
Details of Vehicle 1:
Honda, 5 cd, owned by Peter England
Details of Vehicle 2:
Skoda, 100 cd, owned by Nathan Roy, 150.5 lbs load, 3200 tow
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class Person
{
private String name;
public Person()
{
name="None";
}
public Person(String theName)
{
if(theName!="") //Data
validation
name=theName;
}
public Person(Person theObject)
{
this.name=theObject.name;
}
public String getName() //Accessor
method
{
return name;
}
public void setName(String theName)
//Mutator method
{
if(theName!="") //Data
validation
name=theName;
}
public String toString()
{
return "Name
is:"+name;
}
public boolean equals(Person other)
{
if(this.getName()==
other.getName())
return true;
else
return false;
}
}
class Vehicle
{
String mname;
int cylinders;
Person p;
public Vehicle()
{
mname="None";
cylinders=2;
}
public Vehicle(String mname,int cylinders,Person
obj)
{
if(mname!="") //Data
validation
this.mname=mname;
if(cylinders>2&&cylinders<31)
//Data validation
this.cylinders=
cylinders;
this.p=new
Person(obj.getName());
}
public String getMname() //Accessor
method
{
return mname;
}
public int getCylinders()
//Accessor method
{
return cylinders;
}
public Person getPerson()
//Accessor method
{
return p;
}
public void setPerson(Person
obj) //Mutator method
{
this.p.setName(obj.getName());
}
public void setMname(String
mname) //Mutator method
{
if(mname!="") //Data validation
this.mname=mname;
}
public void setCylinders(int
cylinders) //Mutator method
{
if(cylinders>2&&cylinders<31)
//Data validation
this.cylinders=cylinders;
}
public String toString()
{
return "Name
is:"+mname+" Number of cylinders: "+cylinders;
}
public boolean equals(Object other)
{
if(other instanceof
Vehicle)
{
Vehicle v=(Vehicle) other;
if(getMname()==v.getMname() )
if(getCylinders()== v.getCylinders())
return true;
}
return false;
}
}
class Truck extends Vehicle
{
double load;
int towCapacity;
Truck()
{
load=towCapacity=1;
}
Truck(double load,int towCapacity)
{
if(load>0) //Data validation
this.load=load;
if(towCapacity>0) //Data validation
this.towCapacity=towCapacity;
}
public double getLoad()
//Accessor method
{
return load;
}
public int getTowCapacity()
//Accessor method
{
return
towCapacity;
}
public void setLoad(double
load) //Mutator method
{
if(load>0) //Data validation
this.load=load;
}
public void getTowCapacity(int
towCapacity) //Mutator method
{
if(towCapacity>0) //Data validation
this.towCapacity=towCapacity;
}
public String toString()
{
return "Load is:"+load+"
Tow capacity is: "+towCapacity;
}
public boolean equals(Truck other)
{
if(other instanceof
Truck)
{
Truck t=(Truck) other;
if(getLoad()==t.getLoad() )
if(getTowCapacity()== t.getTowCapacity())
return true;
}
return false;
}
}
public class NewClass {
public static void main(String args[])
{
Person person[]=new
Person[3]; //Creating three persons
person[0]=new
Person("John");
person[1]=new
Person("John");
person[2]=new
Person("Michael Scofield");
Vehicle vehicle[]=new
Vehicle[3];//Creating three trucks
vehicle[0]=new
Vehicle("Ford",8,person[0]);
vehicle[0]=new
Vehicle("Ford",9,person[1]);
vehicle[0]=new
Vehicle("Ferrari",10,person[2]);
Truck truck[]=new
Truck[3];//Creating three trucks
truck[0]=new
Truck(10.6,12);
truck[1]=new
Truck(10.6,12);
truck[2]=new
Truck(20.5,19);
if(person[0].equals(person[1])) //.equals test
System.out.println("Equal");
if
(vehicle[0].equals(vehicle[2])) //.equals test
System.out.println("Equal");
else
System.out.println("Not
equal");
if(truck[0].equals(truck[1])) //.equals test
System.out.println("Equal");
}
}
public class NewClass {
public static void main(String args[])
{
Person person[]=new Person[3]; //Creating three persons
person[0]=new Person("John");
person[1]=new Person("John");
person[2]=new Person("Michael Scofield");
Vehicle vehicle[]=new Vehicle[3];//Creating three trucks
vehicle[0]=new Vehicle("Ford",8,person[0]);
vehicle[1]=new Vehicle("Ford",9,person[1]);
vehicle[2]=new Vehicle("Ferrari",10,person[2]);
Truck truck[]=new Truck[3];//Creating three trucks
truck[0]=new Truck(10.6,12);
truck[1]=new Truck(10.6,12);
truck[2]=new Truck(20.5,19);
if(person[0].equals(person[1])) //.equals test
System.out.println("Equal");
if (vehicle[0].equals(vehicle[2])) //.equals test
System.out.println("Equal");
else
System.out.println("Not equal");
if(truck[0].equals(truck[1])) //.equals test
System.out.println("Equal");
// extra
System.out.println("\n\nTruck details::"); //truck details
for(int i=0;i<3;i++)
System.out.println(vehicle[i].mname+","+vehicle[i].cylinders+"cd, owned by "+ person[i].getName() + "," +truck[i].load + "lbs load, " +truck[i].towCapacity+"tow");
}
}
// person class
class Person
{
private String name;
public Person()
{
name="None";
}
public Person(String theName)
{
if(theName!="") //Data validation
name=theName;
}
public Person(Person theObject)
{
this.name=theObject.name;
}
public String getName() //Accessor method
{
return name;
}
public void setName(String theName) //Mutator method
{
if(theName!="") //Data validation
name=theName;
}
public String toString()
{
return "Name is:"+name;
}
public boolean equals(Person other)
{
if(this.getName()== other.getName())
return true;
else
return false;
}
}
//truck class
class Truck extends Vehicle
{
double load;
int towCapacity;
Truck()
{
load=towCapacity=1;
}
Truck(double load,int towCapacity)
{
if(load>0) //Data validation
this.load=load;
if(towCapacity>0) //Data validation
this.towCapacity=towCapacity;
}
public double getLoad() //Accessor method
{
return load;
}
public int getTowCapacity() //Accessor method
{
return towCapacity;
}
public void setLoad(double load) //Mutator method
{
if(load>0) //Data validation
this.load=load;
}
public void getTowCapacity(int towCapacity) //Mutator method
{
if(towCapacity>0) //Data validation
this.towCapacity=towCapacity;
}
public String toString()
{
return "Load is:"+load+" Tow capacity is: "+towCapacity;
}
public boolean equals(Truck other)
{
if(other instanceof Truck)
{
Truck t=(Truck) other;
if(getLoad()==t.getLoad() )
if(getTowCapacity()== t.getTowCapacity())
return true;
}
return false;
}
}
//vehicle class
class Vehicle
{
String mname;
int cylinders;
Person p;
public Vehicle()
{
mname="None";
cylinders=2;
}
public Vehicle(String mname,int cylinders,Person obj)
{
if(mname!="") //Data validation
this.mname=mname;
if(cylinders>2&&cylinders<31) //Data validation
this.cylinders= cylinders;
this.p=new Person(obj.getName());
}
public String getMname() //Accessor method
{
return mname;
}
public int getCylinders() //Accessor method
{
return cylinders;
}
public Person getPerson() //Accessor method
{
return p;
}
public void setPerson(Person obj) //Mutator method
{
this.p.setName(obj.getName());
}
public void setMname(String mname) //Mutator method
{
if(mname!="") //Data validation
this.mname=mname;
}
public void setCylinders(int cylinders) //Mutator method
{
if(cylinders>2&&cylinders<31) //Data validation
this.cylinders=cylinders;
}
public String toString()
{
return "Name is:"+mname+" Number of cylinders: "+cylinders;
}
public boolean equals(Object other)
{
if(other instanceof Vehicle)
{
Vehicle v=(Vehicle) other;
if(getMname()==v.getMname() )
if(getCylinders()== v.getCylinders())
return true;
}
return false;
}
}

I need the following code to keep the current output but also include somthing similar to...
Required in Java. Thank you.
1. Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in the engine (type int), and owner (type Person given in Listing 8.1 in the textbook and in LMS). Then create a class called Truck that is derived from Vehicle and has additional properties: the load capacity in tons (type double, since it may contain a fractional part) and towing capacity in tons (type double). Give your classes...
I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public class ItemToPurchase { // instance variables private String itemName; private String itemDescription; private int itemPrice; private int itemQuantity; // default constructor public ItemToPurchase() { this.itemName = "none"; this.itemDescription = "none"; this.itemPrice = 0; this.itemQuantity = 0; } public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) { ...
Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...
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;...
Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...
JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...
I'm trying to implement a rest() method for my GameCharacter where if a random number between 0-2 is generated then one or the other character rests and gains back about 5 to 10 health points. I don't know if I'm on the right track. Here's my code so far and the rest() method is located at the bottom: import java.util.Objects; import java.util.Random; /** * this class represents a class for role playing game. */ public class GameCharacter { private String...
Hey guys! Huge part of my grade !! My code works already but I need it so it references to my node list class instead of my array, what would I need to change? My assignment was to create a list from an assignment when we used an array, but I cant make it to work without the array, help! The professor said it was okay to either keep the array or to delete it altogether. package zipcode; import java.io.File; import...
Can anyone identify which OO Design Patterns are being used in the following code?: package mis; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; class helpDeskGuidline{ private void setGuideLine(){ } public void rateService(){ } } public class HelpDeskService extends helpDeskGuidline{ //HelpDeskService class extends helpDeskGuidline this //called inheritance private static int ticketId=1; Ticket ticket; // HelpDeskService class using ticket class object. this is has-A relationship (aggregation) ArrayList<Ticket> allTicket=new ArrayList<>(); HashMap<Ticket,Person> ticketAllocation=new HashMap<>(); HashMap<Person,Integer> assignee=new HashMap<>(); HelpDeskService(){ Person...
Java: Create a class called Vehicle with the following features: a. It has three private data members (instance variables): one is the manufacturer’s name (String manufacturer), the second is the number of cylinders in the engine (int cylinder), and the third is the owner (Person owner). The class Person is described above. b. It has three constructors, a no-argument constructor, a constructor with three parameters, and a copy constructor. The no-argument constructor will set the manufacturer to “None”, cylinder to...