Starting from:

$24.99

CS102 Assignment 4 Solution

Programming 

ATTENTION:
● Compress all of the Java program source files (.java) files into a single zip file.
● The name of the zip file should follow the below convention:
CS102_Sec1_Asgn4_YourSurname_YourName.zip
● Replace the variables “Sec1”, “YourSurname” and “YourName” with your actual section, surname and name.






Determine the wheel radius based on the length of the bus and the number of wheels so that wheels can be positioned without overlaps. Similar to how windows behave, no wheel should go out of the bus. Here you can have assumptions on the given bus length and the number of wheels.



Include a Graphical User Interface for the user to change the bus length and number of wheels. When we click on the update button, the bus should change accordingly. Also include “Play” and
“Pause” buttons to start and stop the animation of your bus.



For animating the bus, you should keep the current horizontal position of the bus in some variable. Painting of the bus should operate based on this variable. Then, using a Timer object, update the position of the bus and repaint it; consecutive rendering of the different positions of the bus will result in an animation. Note that there are multiple Timer classes in Java, and javax.swing.Timer is more suitable for our task (for ActionListener you need to import java.awt.event.ActionListener).

During animation, when the bus touches one side of the window of your frame, it should start moving towards the opposite direction. In other words, the bus will move back and forth between the left and right boundaries of the frame. When we click on the “Stop” button the animation should stop, and when we click on the “Play” button it should resume from the current position of the bus.


Preliminary Submission: You will submit an early version of your solution before the final submission. This version should at least include the following:

• Include the required functionality to draw the parametric bus on screen.


Not completing the preliminary submission on time results in 50% reduction of this assignment’s final grade.

More products