1- Write a Java class that models a Vehicle. There are three types of vehicles (Sedan, SUV, Truck). Every vehicle object should also contain an instance variable that can be used to store the time at which the vehicle has entered the car parking building (Hint: use the java.util.Date class to represent the time). In addition to the constructors, you should provide the following methods: public double getDuration (Date exitTime) this method will return the duration (in minutes) from the time the vehicle entered the parking until the given exitTime. public String getType() this method will return either Sedan or SUV or Truck based on the vehicle type. public void setType(String type) this method will set the type of the vehicle to either Sedan or SUV or Truck. public void setEntryTime(Date entryTime) this method will set the time at which the vehicle has entered the parking.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%
1- Write a Java class that models a Vehicle. There are three types of vehicles (Sedan, SUV, Truck). Every
vehicle object should also contain an instance variable that can be used to store the time at which the
vehicle has entered the car parking building (Hint: use the java.util.Date class to represent the time). In
addition to the constructors, you should provide the following methods:
public double getDuration(Date exitTime) this method will return the duration (in minutes) from
the time the vehicle entered the parking until the given exitTime.
public String getType() this method will return either Sedan or SUV or Truck based on the vehicle
type.
public void setType(String type) this method will set the type of the vehicle to either Sedan or SUV
or Truck.
public void setEntryTime(Date entryTime) this method will set the time at which the vehicle has
entered the parking.
Transcribed Image Text:1- Write a Java class that models a Vehicle. There are three types of vehicles (Sedan, SUV, Truck). Every vehicle object should also contain an instance variable that can be used to store the time at which the vehicle has entered the car parking building (Hint: use the java.util.Date class to represent the time). In addition to the constructors, you should provide the following methods: public double getDuration(Date exitTime) this method will return the duration (in minutes) from the time the vehicle entered the parking until the given exitTime. public String getType() this method will return either Sedan or SUV or Truck based on the vehicle type. public void setType(String type) this method will set the type of the vehicle to either Sedan or SUV or Truck. public void setEntryTime(Date entryTime) this method will set the time at which the vehicle has entered the parking.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT