Implement the classes that are given in the class diagram. Also implement a TestVehicle class where you will create three objects and execute their toString() methods.
Implement the classes that are given in the class diagram. Also implement a TestVehicle class where you will create three objects and execute their toString() methods.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%

Transcribed Image Text:**Java Class Diagram Explanation and Implementation**
**Challenge 3: Vehicle.java, Automobile.java, Tank.java, Truck.java, Car.java, and TestVehicle.java**
Implement the classes as given in the class diagram. Also, implement a `TestVehicle` class where you will create three objects and execute their `toString()` methods.
### Class Diagram Overview:
#### 1. **Vehicle Class**
- **Attributes:**
- `year: int`
- `weight: double`
- **Methods:**
- `Vehicle(int, double)`
- `getYear(): int`
- `setYear(int): void`
- `getWeight(): double`
- `setWeight(double): void`
- `toString(): String`
#### 2. **Automobile Class (inherits from Vehicle)**
- **Attributes:**
- `licensePlate: String`
- `make: String`
- **Methods:**
- `Automobile()`
- `Automobile(int, double, String, String)`
- `getLicensePlate(): String`
- `setLicensePlate(String): void`
- `getMake(): String`
- `setMake(String): void`
- `toString(): String`
- **Derived Classes:**
- **Truck (inherits from Automobile)**
- **Attributes:**
- `towCapacity: double`
- **Methods:**
- `Truck()`
- `Truck(int, double, String, String, double)`
- `getTowCapacity(): double`
- `setTowCapacity(double): void`
- `toString(): String`
- **Car (inherits from Automobile)**
- **Attributes:**
- `maxPassengers: int`
- **Methods:**
- `Car()`
- `Car(int, double, String, String, int)`
- `getMaxPassengers(): int`
- `setMaxPassengers(int): void`
- `toString(): String`
#### 3. **Tank Class (inherits from Vehicle)**
- **Attributes:**
- `armorWidth: double`
- **Methods:**
- `Tank()`
- `Tank(int, double, double)`
- `getArmorWidth(): double`
- `setArmorWidth(double): void`
- `toString(): String`

Transcribed Image Text:The image illustrates a UML class diagram for a Java program, demonstrating the inheritance relationships and methods among the classes `Automobile`, `Truck`, `Car`, and `Tank` within package `assignment2`.
### Class Structure:
1. **Automobile**
- Attributes:
- `licensePlate`: String
- `make`: String
- Methods:
- `Automobile()`: Default constructor
- `Automobile(int, double, String, String)`: Parameterized constructor
- `getLicensePlate()`: Retrieves license plate
- `setLicensePlate(String)`: Sets license plate
- `getMake()`: Retrieves make
- `setMake(String)`: Sets make
- `toString()`: Returns a string representation
2. **Truck** (inherits from `Automobile`)
- Attributes:
- `towCapacity`: double
- Methods:
- `Truck()`: Default constructor
- `Truck(int, double, String, String, double)`: Parameterized constructor
- `getTowCapacity()`: Retrieves tow capacity
- `setTowCapacity(double)`: Sets tow capacity
- `toString()`: Returns a string representation
3. **Car** (inherits from `Automobile`)
- Attributes:
- `maxPassengers`: int
- Methods:
- `Car()`: Default constructor
- `Car(int, double, String, String, int)`: Parameterized constructor
- `getMaxPassengers()`: Retrieves maximum passengers
- `setMaxPassengers(int)`: Sets maximum passengers
- `toString()`: Returns a string representation
4. **Tank** (inherits from `Automobile`)
- Attributes:
- `armorWidth`: double
- Methods:
- `Tank()`: Default constructor
- `Tank(int, double, double)`: Parameterized constructor
- `getArmorWidth()`: Retrieves armor width
- `setArmorWidth(double)`: Sets armor width
- `toString()`: Returns a string representation
### Sample Output:
```
Honda: Year: 2006 weight: 2100.56 License Plate: 1RT245 Make: Honda MaxPassengers: 5
Dodge: Year: 2009 weight: 2500.45 License Plate: 2tu123 Make: Dodge Tow capacity:
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 8 steps with 2 images

Knowledge Booster
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.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education