In this programming assignment, you are asked to add extra functions to a skeleton bouncing program that is provided to you. The aim of the assignment is to give you experience with object-oriented programming, principles of inheritance and polymorphism.This assignment is marked out of 60 marks, with 50 marks being the equivalent of full marks for this assignment. Any excess marks may be used to compensate for loss of marks in other assignments or Coderunner.
Introduction The Bouncing ProgramThe application, as given, is a simple bouncing program designed to let different shapes move around along various paths. Most of the code is already provided for you, but you will need to add more shapes. The program is easy to use: The only user actions are to create shapes based on the classes you will write, and to selectindividual existing shapes on the panel and change their properties.ActionsShape Creation:The user can create a new shape by clicking anywhere within the panel area of the program. The properties of the newly created shape are based on the current values saved in the appropriate UI fields (e.g. height, width border colour, fill colour and path). Once created, the shape will start moving.Selecting/deselecting shapes:A user can select a shape by clicking anywhere on the shape. A selected shape shows all its handles. The user can change the path types/widths/heights/bordercolours/fill colours for all selected shapes by changing the current values with the help of the tools provided at the top of the application interface. (Note: The shapetype itself cannot be modified once a shape has been created.) Clicking on a selected shape will deselect it.ToolsShape ComboBox:The Shape combo box lets you select the shape type for the new shapes that get created when you click on the panel area. In the skeleton application, the combo box is pre-populated with icons for the shape classes you will create. Clicking in the panel area to create a shape as described above will then create a shape of the selected type.Path ComboBox:Users may select one of several moving paths for shapes from the Path combo box.Selecting a new path changes the path of all currently selected shapes. The newly selected path also becomes the current path for any new shapes that the user creates. In the skeleton program, two paths are available: a falling path that sees shapes move from the top of the panel to the bottom with a little bit of back-and-forth sideways movement, and a bouncing path that lets the shape bounce off whichever boundary it hits.WidthTextField:Users may change the current width of new shapes and currently selected shapes by entering a valid number in the width text field and pressing ENTER.HeightTextField:Users may change the current height of new shapes and currently selected shapes by entering a valid number in the height text field and pressing ENTER.COMPSCI 230Assignment ONEComputerScienceSet the currentshape type Set the currentpath typeSet the currentheight & widthSet theAnimation speedSet the currentborder & fill colourCOMPSCI 230 S1 Assignment 012Border Button Users may change the current border colour of new shapes and currently selected shapes by pressing the border button.Fill Button Users may change the current fill colour of new shapes and currently selected shapes by pressing the fill button.Start Button: Starts the animation.Stop Button: Stops the animation.AnimationSlider:Users may use the animation delay slider to adjust the speed of the animation. Popup Menu: The application has a popup menu, which is activated by clicking the right mouse button anywhere in the panel area (on a windows machine). The popup menu contains a menu item called Clear All which allows the user to clear all shapes from the program.What you are to doFirstly, become familiar with the program supplied. The files included in the program are as follows: A1.java AnimationPanel.java MovingShape.java MovingOval.javaDownload all source files from the assignment course page. You are required to modify the program and add afew more shapes into the program. Your assignment is divided into several stages for ease of completion. Pleasecomplete the assignment in order of the stages.In order to complete the assignment, you will need to create additional classes and make changes toAnimationPanel.java, MovingShape.java and A1.java. You need to be familiar in particular with thepurpose of two methods in MovingShape.java, which you may wish to override in the new shape subclassesyou will create: draw(): This method actually draws the shape in question, using an object that is a subclass of theabstract Graphics2D class, which is part of the Java AWT graphics package and extends theGraphics class in that package. You will need to override this method in every shape subclass youcreate, and ensure that the respective shape gets drawn properly. You should find the APIdocumentation of the Graphics2D class useful:https://docs.oracle.com/javase
Assessment criteria: [3 marks] The class hierarchy should be developed sensibly and in accordance with goodobject-oriented programming practice. Do you need to override the draw and/or contains? [4 marks] Users should be able to create a special shape using the current properties in the program. [3 marks] Users should be able to change the fill colour, border colour, size and bouncing path ofselected shapes.Stage 4: The MovingSquarePattern Class (10 marks)You are required to add a MovingSquarePattern subclass to your program. This class should draw a specialpattern based on the mouse-point, the size (i.e. the smallest dimensions from the current width and the currentheight), the current FILL colour (e.g. black), and the current moving path saved in the AnimationPanel. Someexamples are shown as below:
Assessment criteria: [3 marks] The class hierarchy should be developed sensibly and in accordance with goodobject-oriented programming practice. Do you need to override the draw and/or contains? [4 marks] Users should be able to create a new shape pattern using the current FILL colour, size andpath in the program.COMPSCI 230 S1 Assignment 014 [3 marks] Users should be able to change the FILL colour, size and bouncing path of selected patterns.Stage 5: Adding a New Path (10 marks)In this part, you are required to add your own designed path to the bouncing program. The MovingPath is anabstract inner class which contains an abstract method. You are required to add a new subclass which extendsthe MovingPath and implement the move() method.
Assessment criteria [2 marks] The class hierarchy should be developed sensibly and in accordance with goodobject-oriented programming practice. [3 marks] Users should be able to add a new shape that moves in your own designed path. [2 marks] Users should be able to change the bouncing path of selected shapes to your own designedpath. [3 marks] In the markers opinion, your work shows great preparation, creativity or effort.Stage 6: Using an ArrayList (10 marks)The maximum number of shapes that can be stored in your program is 10 at this stage. However, you arerequired to modify the AnimationPanel class which enable users to store more than 10 shapes using anArrayList. Replace the array in AnimationPanel class with an ArrayList. You will need to modify 10different methods in AnimationPanel: mouseClicked, createNewShape, setCurrentPathType,setCurrentWidth, setCurrentHeight, setCurrentBorderColor, setCurrentFillColor,resetMarginSize, clearAllShapes, and, paintComponent.Assessment criteria [2 marks] Shapes are stored in an ArrayList. [3 marks] Users should be able to create a new shape and add it to the ArrayList. [2 marks] Users should be able to remove all shapes from the ArrayList [3 marks] Users should be able to modify the fill and border colours, path, height, width and marginsizes of selected shapes in the ArrayList.Bonus (10 marks)You are now required to get creative and add your own special shape(s) that will make the bouncing programmore interesting! You may want to add Text, Images, 3D shapes, Sound etc into the bouncing program.Assessment criteria: [1 mark] The class hierarchy must be developed sensibly and in accordance with good objectorientedprogramming practice. Do you need to override the draw and/or contains? [2 marks] Users must be able to create a new shape pattern using the current properties. [2 marks] Users must be able to change the fill colour and/or border colour, width, height and bouncingpath of selected shapes. [5 marks] In the markers opinion, your work shows great preparation, creativity or effort.
Reviews
There are no reviews yet.