How can i model foollwing problem statatement into java classe?
I have a class vehincle.
- Vehicles can be of type Trucks, Cars, Scooters, motorcycles.
- Vehicle has a engine.
- engine shold have following contraints
- Petrol Engine and Diesel Engine are types of Engines
- Truck comes with 4 stroke, 12 cylinder Diesel Engine
- Car can have either 4 stroke Petrol Engine or 4 stroke Diesel Engine
- Car can have either 4 Cylinder Engine or 6 Cylinder Engine.
- Motorcycle can have 4 stroke single Cylinder Petrol Engine or 4 stroke twin-cylinder Petrol engine.
- Scooters can have Single Cylinder 2 Stroke Petrol Engine or Single Cylinder 4 stroke Petrol Engine.
- Each engine consists of
- Number of cylinders [1/2/4/6/12 only]
- Number of strokes [2/4 only].
- ‘Engine Number’ is always 6 characters alphanumeric.
- Diesel engine always comes with 4 strokes but Petrol engine can come with either 2 strokes or 4 strokes.
- Only Petrol engines have Spark plugs [One per cylinder]. Diesel Engine cannot have Spark plugs.
- Sparkplug just has sequence number [e.g Car with 6 Cylinder Engine will have Sparkplugs SP1, SP2, SP3, SP4, SP5, SP6]
- Only Trucks and Cars have Oil Pump.
- Each Oil pump has
- Identification number 6 char alphanumeric
- Capacity in cubic centimeters(cc) per seconds [value can be between 1-5]