SlideShare a Scribd company logo
1 of 9
Download to read offline
Driver:
import java.util.Scanner;
//A class that keeps a fleet of different types of vehicles
public class FleetOfVehicles {
//An array of vehicles
private Vehicle[] fleet;
public static final int MAX_VEHICLES = 100;
public FleetOfVehicles()
{
fleet = new Vehicle[MAX_VEHICLES];
}
public Vehicle[] getFleet()
{
return this.fleet;
}
//Adds a new vehicle to the first empty spot in the fleet array
public void addVehicle(Vehicle aV)
{
for(int i=0;i
Solution
import java.util.Scanner;
//A class that keeps a fleet of different types of vehicles
public class FleetOfVehicles {
//An array of vehicles
private Vehicle[] fleet;
public static final int MAX_VEHICLES = 100;
public FleetOfVehicles()
{
fleet = new Vehicle[MAX_VEHICLES];
}
public Vehicle[] getFleet()
{
return this.fleet;
}
//Adds a new vehicle to the first empty spot in the fleet array
public void addVehicle(Vehicle aV)
{
for(int i=0;i 0)
this.cylinders = cylinders;
else
this.cylinders = 0;
}
/**
* @return the ownersName
*/
public String getOwnersName() {
return ownersName;
}
/**
* @param ownersName
* the ownersName to set
*/
public void setOwnersName(String ownersName) {
this.ownersName = ownersName;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if (obj instanceof Vehicle) {
Vehicle vehicle = (Vehicle) obj;
if ((this.getManuName().equals(vehicle.getManuName()))
&& (this.getOwnersName().equals(vehicle.getOwnersName()))
&& (this.getCylinders() == vehicle.getCylinders()))
return true;
else
return false;
} else
return false;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return getManuName() + " " + getCylinders() + " " + getOwnersName();
}
}
public class Truck extends Vehicle {
double loadCap, towCap;
public Truck() {
// TODO Auto-generated constructor stub
super();
setLoadCap(0);
setTowCap(0);
}
/**
* @param manuName
* @param cylinders
* @param ownersName
* @param loadCap
* @param towCap
*/
public Truck(String manuName, int cylinders, String ownersName,
double loadCap, double towCap) {
super(manuName, cylinders, ownersName);
setLoadCap(loadCap);
setTowCap(towCap);
}
/**
* @return the loadCap
*/
public double getLoadCap() {
return loadCap;
}
/**
* @param loadCap
* the loadCap to set
*/
public void setLoadCap(double loadCap) {
if (loadCap > 0)
this.loadCap = loadCap;
else
this.loadCap = 0;
}
/**
* @return the towCap
*/
public double getTowCap() {
return towCap;
}
/**
* @param towCap
* the towCap to set
*/
public void setTowCap(double towCap) {
if (towCap > 0)
this.towCap = towCap;
else
this.towCap = 0;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if (obj instanceof Truck) {
if (super.equals(obj)) {
Truck vehicle = (Truck) obj;
if (this.getLoadCap() == vehicle.getLoadCap()
&& this.getTowCap() == vehicle.getTowCap())
return true;
else
return false;
} else
return false;
} else
return false;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString() + " " + getTowCap() + " " + getLoadCap();
}
}
public class Car extends Vehicle {
double mileage;
int passengers;
public Car() {
// TODO Auto-generated constructor stub
super();
setMileage(0);
setPassengers(0);
}
/**
* @param manuName
* @param cylinders
* @param ownersName
* @param mileage
* @param passengers
*
*/
public Car(String manuName, int cylinders, String ownersName,
double mileage, int passengers) {
super(manuName, cylinders, ownersName);
setMileage(mileage);
setPassengers(passengers);
}
/**
* @return the mileage
*/
public double getMileage() {
return mileage;
}
/**
* @param mileage
* the mileage to set
*/
public void setMileage(double mileage) {
if (mileage > 0)
this.mileage = mileage;
else
this.mileage = 0;
}
/**
* @return the passengers
*/
public int getPassengers() {
return passengers;
}
/**
* @param passengers
* the passengers to set
*/
public void setPassengers(int passengers) {
if (passengers > 0)
this.passengers = passengers;
else
this.passengers = 0;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if (obj instanceof Car) {
if (super.equals(obj)) {
Car vehicle = (Car) obj;
if (this.getMileage() == vehicle.getMileage()
&& this.getPassengers() == vehicle.getPassengers())
return true;
else
return false;
} else
return false;
} else
return false;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString() + " " + getPassengers() + " " + getMileage();
}
}
OUTPUT:
Welcome to the fleet manager
Enter 1: to add a Vehicle
Enter 2: to remove a Vehicle
Enter 9 to quit
1
Enter 1: if it is a car
Enter 2: if it is a truck
Enter 3: if it is unclassified
1
Enter the manufacturer's name
Skoda
Enter the number of cylinders
2
Enter the owner's name
Srinivas
Enter the car's gas mileage
25
Enter the number of passengers
4
The Fleet currently
Skoda 2 Srinivas 4 25.0
Enter 1: to add a Vehicle
Enter 2: to remove a Vehicle
Enter 9 to quit
1
Enter 1: if it is a car
Enter 2: if it is a truck
Enter 3: if it is unclassified
2
Enter the manufacturer's name
Hyundai
Enter the number of cylinders
3
Enter the owner's name
Rajesh
Enter the truck's load capacity
522
Enter the truck's towing capacity
45
The Fleet currently
Skoda 2 Srinivas 4 25.0
Hyundai 3 Rajesh 45.0 522.0
Enter 1: to add a Vehicle
Enter 2: to remove a Vehicle
Enter 9 to quit
2
Enter 1: if it is a car
Enter 2: if it is a truck
Enter 3: if it is unclassified
1
Enter the manufacturer's name
Skoda
Enter the number of cylinders
2
Enter the owner's name
Srinivas
Enter the car's gas mileage
25
Enter the number of passengers
4
The Fleet currently
Hyundai 3 Rajesh 45.0 522.0
Enter 1: to add a Vehicle
Enter 2: to remove a Vehicle
Enter 9 to quit
9
The Fleet currently
Hyundai 3 Rajesh 45.0 522.0
Goodbye

More Related Content

Similar to Driverimport java.util.Scanner;A class that keeps a f.pdf

Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftOleksandr Stepanov
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfadianantsolutions
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップUnity Technologies Japan K.K.
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップUnite2017Tokyo
 
The C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptxThe C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptxVitsRangannavar
 
Mastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonMastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonAEM HUB
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling RewriterJustin Edelson
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classesIntro C# Book
 
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdfVehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdfanujsharmaanuj14
 
#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docxajoy21
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfaggarwalshoppe14
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfANGELMARKETINGJAIPUR
 
Java 102 intro to object-oriented programming in java - exercises
Java 102   intro to object-oriented programming in java - exercisesJava 102   intro to object-oriented programming in java - exercises
Java 102 intro to object-oriented programming in java - exercisesagorolabs
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfajantha11
 
Programimport java.util.; import java.io.; class FoodTruck.pdf
Programimport java.util.; import java.io.; class FoodTruck.pdfProgramimport java.util.; import java.io.; class FoodTruck.pdf
Programimport java.util.; import java.io.; class FoodTruck.pdfapleathers
 

Similar to Driverimport java.util.Scanner;A class that keeps a f.pdf (20)

Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
I need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdfI need to do the followingAdd a new item to the inventory m.pdf
I need to do the followingAdd a new item to the inventory m.pdf
 
C++: Interface as Concept
C++: Interface as ConceptC++: Interface as Concept
C++: Interface as Concept
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
 
The C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptxThe C# programming laguage delegates notes Delegates.pptx
The C# programming laguage delegates notes Delegates.pptx
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Mastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonMastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin Edelson
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdfVehicle.javapublic class Vehicle {    Declaring instance var.pdf
Vehicle.javapublic class Vehicle {    Declaring instance var.pdf
 
#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx
 
4.Spring IoC&DI(Spring Ioc실습_어노테이션 기반)
4.Spring IoC&DI(Spring Ioc실습_어노테이션 기반)4.Spring IoC&DI(Spring Ioc실습_어노테이션 기반)
4.Spring IoC&DI(Spring Ioc실습_어노테이션 기반)
 
Unit4_2.pdf
Unit4_2.pdfUnit4_2.pdf
Unit4_2.pdf
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdf
 
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
 
Java 102 intro to object-oriented programming in java - exercises
Java 102   intro to object-oriented programming in java - exercisesJava 102   intro to object-oriented programming in java - exercises
Java 102 intro to object-oriented programming in java - exercises
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
 
Programimport java.util.; import java.io.; class FoodTruck.pdf
Programimport java.util.; import java.io.; class FoodTruck.pdfProgramimport java.util.; import java.io.; class FoodTruck.pdf
Programimport java.util.; import java.io.; class FoodTruck.pdf
 

More from arihantstoneart

Let S = I + TT H rightarrow H, where T is linear and bounded. Show.pdf
Let S = I + TT H  rightarrow H, where T is linear and bounded. Show.pdfLet S = I + TT H  rightarrow H, where T is linear and bounded. Show.pdf
Let S = I + TT H rightarrow H, where T is linear and bounded. Show.pdfarihantstoneart
 
It is a nanotechnology question. In which you are able to pick one m.pdf
It is a nanotechnology question. In which you are able to pick one m.pdfIt is a nanotechnology question. In which you are able to pick one m.pdf
It is a nanotechnology question. In which you are able to pick one m.pdfarihantstoneart
 
I have this problem that I was given in class, but I cant for the .pdf
I have this problem that I was given in class, but I cant for the .pdfI have this problem that I was given in class, but I cant for the .pdf
I have this problem that I was given in class, but I cant for the .pdfarihantstoneart
 
Implement this in Java Method to determine if a particular elemen.pdf
Implement this in Java Method to determine if a particular elemen.pdfImplement this in Java Method to determine if a particular elemen.pdf
Implement this in Java Method to determine if a particular elemen.pdfarihantstoneart
 
If an image is represented using 400 x 300 pixels and each pixel is .pdf
If an image is represented using 400 x 300 pixels and each pixel is .pdfIf an image is represented using 400 x 300 pixels and each pixel is .pdf
If an image is represented using 400 x 300 pixels and each pixel is .pdfarihantstoneart
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfarihantstoneart
 
Hyposecretion of insulin is referred to as Type I diabetes insipidus.pdf
Hyposecretion of insulin is referred to as  Type I diabetes insipidus.pdfHyposecretion of insulin is referred to as  Type I diabetes insipidus.pdf
Hyposecretion of insulin is referred to as Type I diabetes insipidus.pdfarihantstoneart
 
How are the forces of diffusion and electrical force responsible for.pdf
How are the forces of diffusion and electrical force responsible for.pdfHow are the forces of diffusion and electrical force responsible for.pdf
How are the forces of diffusion and electrical force responsible for.pdfarihantstoneart
 
How does each of the differences between prokaryotes and eukaryotes .pdf
How does each of the differences between prokaryotes and eukaryotes .pdfHow does each of the differences between prokaryotes and eukaryotes .pdf
How does each of the differences between prokaryotes and eukaryotes .pdfarihantstoneart
 
For MIMO system, (a) Please talk about the advantage and disadvantag.pdf
For MIMO system, (a) Please talk about the advantage and disadvantag.pdfFor MIMO system, (a) Please talk about the advantage and disadvantag.pdf
For MIMO system, (a) Please talk about the advantage and disadvantag.pdfarihantstoneart
 
Explain why and give examples. In OO programming Polymorphism is on.pdf
Explain why and give examples. In OO programming Polymorphism is on.pdfExplain why and give examples. In OO programming Polymorphism is on.pdf
Explain why and give examples. In OO programming Polymorphism is on.pdfarihantstoneart
 
Eukaryotic cells modify RNA after transcription What critical RNA pr.pdf
Eukaryotic cells modify RNA after transcription  What critical RNA pr.pdfEukaryotic cells modify RNA after transcription  What critical RNA pr.pdf
Eukaryotic cells modify RNA after transcription What critical RNA pr.pdfarihantstoneart
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfarihantstoneart
 
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdf
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdfColumbus Incorporated just paid $4.3 per share dividend yesterday (i.pdf
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdfarihantstoneart
 
Anatomy Question Please Answer them all.A. Using a punnett square.pdf
Anatomy Question Please Answer them all.A. Using a punnett square.pdfAnatomy Question Please Answer them all.A. Using a punnett square.pdf
Anatomy Question Please Answer them all.A. Using a punnett square.pdfarihantstoneart
 
A person is lost in the desert. (S)he has no water and after a coupl.pdf
A person is lost in the desert. (S)he has no water and after a coupl.pdfA person is lost in the desert. (S)he has no water and after a coupl.pdf
A person is lost in the desert. (S)he has no water and after a coupl.pdfarihantstoneart
 
2. Describe an advantage and a limitation to tracing ancestry with b.pdf
2. Describe an advantage and a limitation to tracing ancestry with b.pdf2. Describe an advantage and a limitation to tracing ancestry with b.pdf
2. Describe an advantage and a limitation to tracing ancestry with b.pdfarihantstoneart
 
Write your thought on the following1. petroski notes that most en.pdf
Write your thought on the following1. petroski notes that most en.pdfWrite your thought on the following1. petroski notes that most en.pdf
Write your thought on the following1. petroski notes that most en.pdfarihantstoneart
 
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdf
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdfYou have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdf
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdfarihantstoneart
 
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdf
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdfWith X-linked inheritance, the X chromosome is transmitted in a diffe.pdf
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdfarihantstoneart
 

More from arihantstoneart (20)

Let S = I + TT H rightarrow H, where T is linear and bounded. Show.pdf
Let S = I + TT H  rightarrow H, where T is linear and bounded. Show.pdfLet S = I + TT H  rightarrow H, where T is linear and bounded. Show.pdf
Let S = I + TT H rightarrow H, where T is linear and bounded. Show.pdf
 
It is a nanotechnology question. In which you are able to pick one m.pdf
It is a nanotechnology question. In which you are able to pick one m.pdfIt is a nanotechnology question. In which you are able to pick one m.pdf
It is a nanotechnology question. In which you are able to pick one m.pdf
 
I have this problem that I was given in class, but I cant for the .pdf
I have this problem that I was given in class, but I cant for the .pdfI have this problem that I was given in class, but I cant for the .pdf
I have this problem that I was given in class, but I cant for the .pdf
 
Implement this in Java Method to determine if a particular elemen.pdf
Implement this in Java Method to determine if a particular elemen.pdfImplement this in Java Method to determine if a particular elemen.pdf
Implement this in Java Method to determine if a particular elemen.pdf
 
If an image is represented using 400 x 300 pixels and each pixel is .pdf
If an image is represented using 400 x 300 pixels and each pixel is .pdfIf an image is represented using 400 x 300 pixels and each pixel is .pdf
If an image is represented using 400 x 300 pixels and each pixel is .pdf
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
 
Hyposecretion of insulin is referred to as Type I diabetes insipidus.pdf
Hyposecretion of insulin is referred to as  Type I diabetes insipidus.pdfHyposecretion of insulin is referred to as  Type I diabetes insipidus.pdf
Hyposecretion of insulin is referred to as Type I diabetes insipidus.pdf
 
How are the forces of diffusion and electrical force responsible for.pdf
How are the forces of diffusion and electrical force responsible for.pdfHow are the forces of diffusion and electrical force responsible for.pdf
How are the forces of diffusion and electrical force responsible for.pdf
 
How does each of the differences between prokaryotes and eukaryotes .pdf
How does each of the differences between prokaryotes and eukaryotes .pdfHow does each of the differences between prokaryotes and eukaryotes .pdf
How does each of the differences between prokaryotes and eukaryotes .pdf
 
For MIMO system, (a) Please talk about the advantage and disadvantag.pdf
For MIMO system, (a) Please talk about the advantage and disadvantag.pdfFor MIMO system, (a) Please talk about the advantage and disadvantag.pdf
For MIMO system, (a) Please talk about the advantage and disadvantag.pdf
 
Explain why and give examples. In OO programming Polymorphism is on.pdf
Explain why and give examples. In OO programming Polymorphism is on.pdfExplain why and give examples. In OO programming Polymorphism is on.pdf
Explain why and give examples. In OO programming Polymorphism is on.pdf
 
Eukaryotic cells modify RNA after transcription What critical RNA pr.pdf
Eukaryotic cells modify RNA after transcription  What critical RNA pr.pdfEukaryotic cells modify RNA after transcription  What critical RNA pr.pdf
Eukaryotic cells modify RNA after transcription What critical RNA pr.pdf
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdf
 
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdf
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdfColumbus Incorporated just paid $4.3 per share dividend yesterday (i.pdf
Columbus Incorporated just paid $4.3 per share dividend yesterday (i.pdf
 
Anatomy Question Please Answer them all.A. Using a punnett square.pdf
Anatomy Question Please Answer them all.A. Using a punnett square.pdfAnatomy Question Please Answer them all.A. Using a punnett square.pdf
Anatomy Question Please Answer them all.A. Using a punnett square.pdf
 
A person is lost in the desert. (S)he has no water and after a coupl.pdf
A person is lost in the desert. (S)he has no water and after a coupl.pdfA person is lost in the desert. (S)he has no water and after a coupl.pdf
A person is lost in the desert. (S)he has no water and after a coupl.pdf
 
2. Describe an advantage and a limitation to tracing ancestry with b.pdf
2. Describe an advantage and a limitation to tracing ancestry with b.pdf2. Describe an advantage and a limitation to tracing ancestry with b.pdf
2. Describe an advantage and a limitation to tracing ancestry with b.pdf
 
Write your thought on the following1. petroski notes that most en.pdf
Write your thought on the following1. petroski notes that most en.pdfWrite your thought on the following1. petroski notes that most en.pdf
Write your thought on the following1. petroski notes that most en.pdf
 
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdf
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdfYou have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdf
You have two cell lines, a macrophage cell line and a CD4 T-cell lin.pdf
 
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdf
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdfWith X-linked inheritance, the X chromosome is transmitted in a diffe.pdf
With X-linked inheritance, the X chromosome is transmitted in a diffe.pdf
 

Recently uploaded

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Driverimport java.util.Scanner;A class that keeps a f.pdf

  • 1. Driver: import java.util.Scanner; //A class that keeps a fleet of different types of vehicles public class FleetOfVehicles { //An array of vehicles private Vehicle[] fleet; public static final int MAX_VEHICLES = 100; public FleetOfVehicles() { fleet = new Vehicle[MAX_VEHICLES]; } public Vehicle[] getFleet() { return this.fleet; } //Adds a new vehicle to the first empty spot in the fleet array public void addVehicle(Vehicle aV) { for(int i=0;i Solution import java.util.Scanner; //A class that keeps a fleet of different types of vehicles public class FleetOfVehicles { //An array of vehicles private Vehicle[] fleet; public static final int MAX_VEHICLES = 100; public FleetOfVehicles() { fleet = new Vehicle[MAX_VEHICLES];
  • 2. } public Vehicle[] getFleet() { return this.fleet; } //Adds a new vehicle to the first empty spot in the fleet array public void addVehicle(Vehicle aV) { for(int i=0;i 0) this.cylinders = cylinders; else this.cylinders = 0; } /** * @return the ownersName */ public String getOwnersName() { return ownersName; } /** * @param ownersName * the ownersName to set */ public void setOwnersName(String ownersName) { this.ownersName = ownersName; } @Override public boolean equals(Object obj) { // TODO Auto-generated method stub if (obj instanceof Vehicle) { Vehicle vehicle = (Vehicle) obj; if ((this.getManuName().equals(vehicle.getManuName())) && (this.getOwnersName().equals(vehicle.getOwnersName())) && (this.getCylinders() == vehicle.getCylinders())) return true; else
  • 3. return false; } else return false; } @Override public String toString() { // TODO Auto-generated method stub return getManuName() + " " + getCylinders() + " " + getOwnersName(); } } public class Truck extends Vehicle { double loadCap, towCap; public Truck() { // TODO Auto-generated constructor stub super(); setLoadCap(0); setTowCap(0); } /** * @param manuName * @param cylinders * @param ownersName * @param loadCap * @param towCap */ public Truck(String manuName, int cylinders, String ownersName, double loadCap, double towCap) { super(manuName, cylinders, ownersName); setLoadCap(loadCap); setTowCap(towCap); } /** * @return the loadCap */ public double getLoadCap() {
  • 4. return loadCap; } /** * @param loadCap * the loadCap to set */ public void setLoadCap(double loadCap) { if (loadCap > 0) this.loadCap = loadCap; else this.loadCap = 0; } /** * @return the towCap */ public double getTowCap() { return towCap; } /** * @param towCap * the towCap to set */ public void setTowCap(double towCap) { if (towCap > 0) this.towCap = towCap; else this.towCap = 0; } @Override public boolean equals(Object obj) { // TODO Auto-generated method stub if (obj instanceof Truck) { if (super.equals(obj)) { Truck vehicle = (Truck) obj; if (this.getLoadCap() == vehicle.getLoadCap() && this.getTowCap() == vehicle.getTowCap())
  • 5. return true; else return false; } else return false; } else return false; } @Override public String toString() { // TODO Auto-generated method stub return super.toString() + " " + getTowCap() + " " + getLoadCap(); } } public class Car extends Vehicle { double mileage; int passengers; public Car() { // TODO Auto-generated constructor stub super(); setMileage(0); setPassengers(0); } /** * @param manuName * @param cylinders * @param ownersName * @param mileage * @param passengers * */ public Car(String manuName, int cylinders, String ownersName, double mileage, int passengers) { super(manuName, cylinders, ownersName); setMileage(mileage);
  • 6. setPassengers(passengers); } /** * @return the mileage */ public double getMileage() { return mileage; } /** * @param mileage * the mileage to set */ public void setMileage(double mileage) { if (mileage > 0) this.mileage = mileage; else this.mileage = 0; } /** * @return the passengers */ public int getPassengers() { return passengers; } /** * @param passengers * the passengers to set */ public void setPassengers(int passengers) { if (passengers > 0) this.passengers = passengers; else this.passengers = 0; } @Override public boolean equals(Object obj) {
  • 7. // TODO Auto-generated method stub if (obj instanceof Car) { if (super.equals(obj)) { Car vehicle = (Car) obj; if (this.getMileage() == vehicle.getMileage() && this.getPassengers() == vehicle.getPassengers()) return true; else return false; } else return false; } else return false; } @Override public String toString() { // TODO Auto-generated method stub return super.toString() + " " + getPassengers() + " " + getMileage(); } } OUTPUT: Welcome to the fleet manager Enter 1: to add a Vehicle Enter 2: to remove a Vehicle Enter 9 to quit 1 Enter 1: if it is a car Enter 2: if it is a truck Enter 3: if it is unclassified 1 Enter the manufacturer's name Skoda Enter the number of cylinders 2 Enter the owner's name
  • 8. Srinivas Enter the car's gas mileage 25 Enter the number of passengers 4 The Fleet currently Skoda 2 Srinivas 4 25.0 Enter 1: to add a Vehicle Enter 2: to remove a Vehicle Enter 9 to quit 1 Enter 1: if it is a car Enter 2: if it is a truck Enter 3: if it is unclassified 2 Enter the manufacturer's name Hyundai Enter the number of cylinders 3 Enter the owner's name Rajesh Enter the truck's load capacity 522 Enter the truck's towing capacity 45 The Fleet currently Skoda 2 Srinivas 4 25.0 Hyundai 3 Rajesh 45.0 522.0 Enter 1: to add a Vehicle Enter 2: to remove a Vehicle Enter 9 to quit 2 Enter 1: if it is a car Enter 2: if it is a truck Enter 3: if it is unclassified 1
  • 9. Enter the manufacturer's name Skoda Enter the number of cylinders 2 Enter the owner's name Srinivas Enter the car's gas mileage 25 Enter the number of passengers 4 The Fleet currently Hyundai 3 Rajesh 45.0 522.0 Enter 1: to add a Vehicle Enter 2: to remove a Vehicle Enter 9 to quit 9 The Fleet currently Hyundai 3 Rajesh 45.0 522.0 Goodbye