Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Following is a guideline to implement the simulator. Object-Oriented design has to be implemented as follows due to the objective of this course. Vehicle abstract

Following is a guideline to implement the simulator. Object-Oriented design has to be implemented as follows due to the objective of this course. Vehicle abstract class Superclass for all vehicles. Properties: X coordinate (int), Y coordinate (int), alive (Boolean) Constructor to initialize all properties. Move Method : a) Called for all alive vehicles each turn b) Increments or decrements either x or y coordinates by 1. Any type of vehicle should throw an exception if the move method is invoked even when the vehicle is dead. toString method should be provided.

Car class Inherits from a vehicle. Properties: type (string) Constructor calling the super constructor and initializing the properties and setting the type to CAR. Move method inherited from the vehicle class. toString method overriding from the vehicle class. Truck class Inherits from a vehicle class. Properties: type (string) Constructor calling the super constructor and initializing the properties and setting the type to TRUCK Move method overrides the Move method in the Vehicle class. Move method: a) Move method for truck is allowed 2 increment/decrements. b) Either x or y can increment/decrement, by 2. c) Both x and y can increment/decrement by 2. d) Probability for b and c happening should be 50:50 SportsCar class Inherits from a Vehicle class. Properties: type (string) Constructor calling the super constructor and initializing the properties and setting the type to SPORTSCAR Move method overrides the Move method from the Vehicle class. SportsCar is allowed one more life Move method: a) Move method for SportsCar is allowed 3 increment/decrements. b) Abstract value for movement always has to be 3 and has to move freely. For example: (0,0) - > (2, -1) (2, -1) - > (5, -1) (5, -1) - > (4, -3) toString method overriding from the vehicle class.

Tractor class Inherits from a Vehicle class. Properties: type (string) Constructor calling the super constructor and initializing the properties and setting the type to TRACTOR Move method overrides the Move method from the Vehicle class. Move method: a) Move method for Tractor is allowed 2 increment/decrements. b) Abstract value for movement always has to be 2 and has to move freely. For example: (0,0) - > (2, 0) (2, 0) - > (3, 1) (3, 1) - > (2, 2) c) Not move at all. d) Probability of b and c happening should be 50:50 toString method overriding from the vehicle class. Field class Includes all the vehicles.

Properties: 4 vertex of the field (array of ints [quadrant number][x, y coordinates (store this value in whichever form you want)]) Array of vehicles Copyright 2019 5 CA-OOPJV v1-0 Project 2019-0828 Constructor: a) Takes a parameter to determine the length of the quadrant which is always a right triangle. b) Takes parameters for how many of each vehicles are to be populated. At least 4 of each vehicle types has to be populated. (Since the result is to sort out the top 3 longest survivors. c) Populating the vehicles, each vehicles are positioned to random positions within a field. d) Populated vehicles are stored in the array of vehicle class. (Using ArrayList is also possible.) When a vehicle steps outside of the field, field class should kill the vehicle. You are free to make extra methods that does not violate the guideline. Simulator class Simulator class has the Field class. In each turn, Simulator class should invoke the Move method of each vehicles inside the Field object. Simulator class should be able to keep track of each vehicles movements and take a record of it. (You are free to store this data anywhere in the application) Dead vehicles Move methods should not be invoked. In each turn, console should display the current position of each position. For example: Turn 3: SPORTSCAR 1 (DEAD), SPORTSCAR 2 (2, 3), TRUCK 5 (DEAD) When all the vehicles are dead Simulator class should be able to display the track of each vehicles, how many turns it survived. For example: Simulation terminated in 34 turns in the field of 34*34 Top 3 SPORTSCARS 1. SPORTSCAR 6 survived 33 turns (0,0) - > (2, 0) - > (3, 1) -> (2, 2) (34, 1) 2. SPORTSCAR 2 survived 29 turns (0,0) - > (2, 0) - > (3, 1) -> (2, 2) (34, 1) Top 3 TRUCKS 1. Aside from turns, Simulator class should also be able to measure real-time simulation duration and display them at the end. For example: Simulation took total 36 seconds until all vehicles are terminated. Try-catch block is mandatory to catch the exception from the Move method. Like mentioned on the Vehicle class specification, Move method throws an exception when its invoked after the vehicles death. Simulator class is to include the Run method to start off the simulator. Main class This is the class to include the main method. This class is to have the Simulator class. Main method is only allowed to have 3 features: - Prompt User to input values for Simulator configuration: o Length of each quadrants. o Number of vehicles. o Number of each vehicle types. When the user input is invalid, it needs to request a new value from the user until a valid value is entered. - Initialize the Simulator class according to user input. - Invoke Run method in the Simulator class. Providing GUI using JavaFX is a bonus

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions