Question: Object - Oriented Approach Problem PART 1 ! ! Our aim in this question is to learn the use of the methods. The language is

Object-Oriented Approach Problem PART1!!Our aim in this question is to learn the use of the methods. The language is Java. Please do not use complex functions . Please show the implementation. We cannot use these and similar ones (So we should simplify them and write them in detail.):
str.split(), str.replaceFirst(), str.replaceAll(), str.replace(), append(), str.hashCode(), StringBuilder (strictly forbidden), any specific function or method
It is allowed to use:
lowerCase , upperCase , str1+ str2, concat , lastIndexOf(ch, fromIndex), lastIndexOf(s), lastIndexOf(s, fromIndex), str.substring(), substring(beginIndex), substring(beginIndex, endIndex), str.startsWith(), str.endsWith(), str.contains(), str1.equals(str2) and so on... n this h omewoOOOOOOOrk, you will implement a program with an object-oriented approach.
1. Implement a Vehicle class with the following UML diagram. Vehicle -plateNumber : String -size: int +Vehicle (plateNumber: String, size: int)
+getPlateNumber(): String
+getSize(): int
+getVehicleInfo(): String
A Vehicle object represents a vehicle with a license plate number and size.
The data field of size may take the values of 1,2, and 4.
(You may simply assume that 1: motorcycle, 2: car, 4: truck)
You have to use this keyword in the implementation of the constructor.
Consider the following example which demonstrates the creation of a Vehicle object:
Vehicle vehicle = new Vehicle("34CSE1141",2);
getPlateNumber method should return the plate number of the vehicle.
getSize method should return the size of the vehicle.
getVehicleInfo method returns a string containing the vehicles license plate
number and the size of the vehicle.
An example string as the following:
Vehicle Info
Plate Number : 34CSE1141
Size : 2
2. Implement a ParkPlace class with the following UML diagram.
A ParkPlace object represents a suitable place that the vehicle will be parked.
A ParkPlace object is created with a size of the vehicle and the vehicle itself.
You have to use this keyword in the implementation of the constructor.
ParkPlace
-size: int
-vehicle: Vehicle
+ParkPlace (vehicle: Vehicle)
+getSize(): int
+getVehicle(): Vehicle
A ParkPlace object represents a suitable place that the vehicle will be parked.
A ParkPlace object is created with a size of the vehicle and the vehicle itself.
You have to use this keyword in the implementation of the constructor Consider the following example which demonstrates the creation of a ParkPlace
object:
ParkPlace parkPlace = new ParkPlace(vehicle);
getSize method returns the size of the ParkPlace object.
o The size of the ParkPlace might be suitable for a motorcycle, a car, or a truck.
getVehicle method returns the Vehicle object of the ParkPlace object.
o This represents which vehicle is parked in that place

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!