Based on the requirements and use cases, identify the main objects of the system and analyze how they interact and relate to each other...
public abstarct class vechile{
private String licencePlate;
private String type;
public vechile(String licencePlate, String type){
this.licencePlate= licencePlate;
this.type= type;
}}
we will implement it like
public class car extend vechile{
public car(String licnecplate){
super(licenceplate, vechiletype.car)
}
}
we make oject vechioe type
public enum vechiletype{
MotorCycle(1), Car(2), Truck(3);
private final int size;
vechiletype(int size){
this.size=size;
}
public int getseize(){
return size;
}
}
public enum spottype{
SMALL(1), MEDIUM(2), LARGE(3);
private final int size;
spottype(int size){
this.size=size;
}
public int getseize(){
return size;
}
}
Now we will do pricing startegy. we weill use interface and impliment our funciton with that.
public interface PricingStrategy{
double calculateFee(long durationMinutes, VehicleType vehicleType);
}
public class hourlypricing impliment PricingStrategy{
private final Map<vechiletype, doube> hourlyrates;
public hourlypricing(Map<vechiletype, doube> hourlyrates){
this.hourlyrates=hourlyrates;
}
@override
public double calculateFee(long durationMinutes, VehicleType vehicleType){
double hours = Math.ceil(durationMinutes / 60.0);
return hours * hourlyRates.getOrDefault(
vehicleType, 5.0);
}
}
public class FlatRatePricing implements PricingStrategy {
private final double flatRate;
public FlatRatePricing(double flatRate) {
this.flatRate = flatRate;
}
@Override
public double calculateFee(long durationMinutes,
VehicleType vehicleType) {
return flatRate;
}
}
public class AdvanceBookingPricing
implements PricingStrategy {
private final double bookingCharge;
private final double hourlyRate;
public AdvanceBookingPricing(
double bookingCharge,
double hourlyRate) {
this.bookingCharge = bookingCharge;
this.hourlyRate = hourlyRate;
}
@Override
public double calculateFee(
long durationMinutes,
VehicleType vehicleType) {
double hours =
Math.ceil(durationMinutes / 60.0);
return bookingCharge + (hours * hourlyRate);
}
}
For each class, define the attributes (data) it will hold and the methods (functions) that operate on the attributes. Ensure they align with the object's responsibilities and adhere to the principle of encapsulation. Write your code in the code editor below.
Explain design tradeoffs you considered. Check and explain whether your design adheres to SOLID principles. Explain how your design can handle changes in scale and whether it would be easy to extend with new functionalities. Identify areas for future improvement...