Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMPSCI 230

Assignment TWO

2022


Introduction - The Bouncing Program


This assignment project aims to develop and reinforce skills in object-oriented programming. The context of this project is          extended from A1. The assignment project contains three parts, and each part has several tasks. You will generally need to          complete one part before continuing to the next. This document only provides a summary of the requirement of A2. It would be best to refer to the PowerPoint slides and CodeRunner questions for more information.

 

Assessment Criteria

Complete CodeRunner questions and submit the entire program via the assignment dropbox (https://adb.auckland.ac.nz/) at   any time from the first submission date up until the final due date. You will receive an electronic receipt. Submit a single zip file containing all source files remember to include your name, UPI and a comment at the beginning of each file.

You may make more than one submission, but note that every submission that you make replaces your previous submission.          Submit ALL your files in every submission. Only your very latest submission will be marked. Please double check that you have  included all the files required to run your program in the zip file before you submit it. Your program must compile and run to gain any marks.

Description

Task 1: Grapchis [4 marks]

Download the template zip file from Canvas. Complete task 1 without using CodeRunner. Your program should support the following:

●     Users would be able to create new shapes 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. width, height and fill colour).

     Once created, the shape will start moving.

     Users would be able to select a shape or multiples shapes by clicking anywhere on the shape.

     A selected shape shows all its handles.

○     The user can change the widths/heights/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 shape type and path type cannot be modified once a shape has been created.

     New shapes are created based on the updated values.

     Users would be able to deselect shape(s) by clicking anywhere on the shape(s).

You should check the PowerPoint slides for the details.

Task 2: The Text property [6 marks]

You must modify the Shape class hierarchy to allow text to be displayed when a shape is painted. Text should be shown in the bottom-left corner of a shape.

 

Your program should support the following:

     Users would be able to create new shapes using the specified text at the top of the program.

     Users would be able to change the text for all selected shapes by changing the current text at the top of the program.

Complete the CodeRunner questions (4 marks) and the template program (2 marks). CodeRunner checks if the text field is           correctly defined in the superclass. However, CodeRunner cannot do any drawings. You have to modify the template program so that users can create shapes with text shown at the bottom-left corner. You should check the PowerPoint slides for the details.

Task 3: The Load Button [4 marks]

You must implement the Loadbutton to import a list of shapes from a given text file. The text file contains three integers per      line. The first integer represents the shape type, the second integer represents the x coordinate, and the third integer represents the y coordinate. For example, A2.txt contains the following:

0,40,50

2,200,300

1,250,350

The method reads the contents from the text file, creates and adds 3 shapes into the array list. They are:

   Rectangle, x=40, y=50, width=50, height=100, marginWidth=600 marginHeight=800 color=orange, text=A2

   Oval, x=200, y=300, width=50, height=100, marginWidth=600 marginHeight=800 color=orange, text=A2

   Square, x=250, y=350, width=50, height=50, marginWidth=600 marginHeight=800 color=orange, text=A2

Note: width, height, marginWidth, marginHeight, color and text are based on the current values stored in the AnimationViewer class.

Your program should support the following:

      Users would be able to add new shapes by clicking the Load button. The method clears the filename in the JTextField

if shapes are added to the program successfully.

     If the text file does not exist, the method displays "Invalid filename ." in the JTextField.

Complete the CodeRunner questions (1 mark) and the template program (3 marks). CodeRunner only checks if the method can      read the contents of a text file correctly. You will need to complete the template program such that users would be able to click the button to create shapes based on the data read from a text file.

MARKING SCHEME

The total marks of this assignment is 16.

1 mark

Comments at the top of each class (containing your name, upi, and a brief description of the class)

1 mark

The code is self-documenting (good and meaningful variable names, etc).

Task1

 

1 mark

Users would be able to create new shapes with correct properties.

1 mark

Users would be able to change the properties (i.e. width/height/fill color) of all selected shapes.

1 mark

New shape are created based on the updated values

1 mark

Shapes are moving around the bouncing area correctly.

Task2

 

4 marks

CodeRunner questions

1 mark

Text is drawn at the bottom-left corner of each shape

0.5 marks

User would be able to change the text property of all selected shapes.

0.5 marks

User would be able to create a new shape using the given text property

Task3

 

1 mark

CodeRunner questions

1 mark

Users would be able to load shapes from a text file.

1 mark

If shapes are added successfully, the method clears the filename in the filename JTextField

1 mark

If the file does not exist, the method sets an error message in the filename JTextField

ACADEMIC INTEGRITY

The purpose of this assignment is to help you develop a working understanding of some of the concepts you are taught in the  lectures. We expect that you will want to use this opportunity to be able to answer the corresponding questions in the tests and

exam. We expect that the work done on this assignment will be your own work. We expect that you will think carefully about any problems you come across, and try to solve them yourself before you ask anyone for help. The following sources of help are not   acceptable:

     Getting another student, or other third party to instruct you on how to design classes or have them write code for you.

     Taking or obtaining an electronic copy of someone elses work, or part thereof.

●     Give a copy of your work, or part thereof, to someone else.

●     Using code from past sample solutions or from online sources dedicated to this assignment.

The Computer Science department uses copy detection tools on all submissions. Submissions found to share code with those of other people will be detected and disciplinary action will be taken. To ensure that you are not unfairly accused of cheating:

     Always do individual assignments by yourself.

     Never give any other person your code or sample solutions in your possession.

●     Never put your code in a public place (e.g., Piazza, forum, your web site).

     Never leave your computer unattended. You are responsible for the security of your account.

●     Ensure you always remove your USB flash drive from the computer before you log off, and keep it safe.