联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> javajava

日期:2018-08-26 06:24

代做java programming assignment、代写java编程作业、代写java 游戏作业

Introduction

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 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.

Due date

Due: 11:59 pm Friday 24th August 2018

Worth: 7.5% of the final mark

Introduction - the bouncing program

The 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 create your own shapes in order

to see real animation. The program is easy to use: The only user actions are to create shapes based on the classes

you will write, and to select individual existing shapes on the panel and change their properties.

Actions

Creating a shape:

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. Note that this will not work in

the skeleton application because you have not added

any shape classes yet.

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 then change the path types / widths / heights

/border colours / 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 itself cannot be modified once a shape has been created.) Clicking on a selected shape will deselect it.

Tools

Shape combo box: 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 combo box: 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.

Width text field: Users may change the current width for new shapes and currently selected shapes by

entering a valid number in the width text field and pressing “ENTER”.

COMPSCI 230

Assignment ONE

Computer

Science

Set the current

shape type Set the current

path type

(pattern of

movement)

Set the current

height & width

Set the

animation speed

Set the current

border & fill colour

COMPSCI 230 S2 - Assignment 01

2

Height text field: 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”.

Border 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.

Animation slider: 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 do

Firstly, become familiar with the program supplied. The Java files included in the skeleton program are as

follows:

? A1.java

? AnimationPanel.java

? MovingShape.java

Download all source files from the assignment course page. The skeleton program is incomplete. You are

required to modify the program and add a few more shapes into the program. Your assignment is divided into

several stages for ease of completion. Please complete the assignment in order of the stages.

In order to complete the assignment, you will need to create additional classes and make changes to

AnimationPanel.java and, in stage 6, to MovingShape.java and A1.java. You need to be familiar in

particular with the purpose of two methods in MovingShape.java, which you may wish to override in the new

shape subclasses you will create:

? draw(): This method actually draws the shape in question, using an object that is a subclass of the

abstract Graphics2D class, which is part of the Java AWT graphics package and extends the

Graphics class in that package. In fact, while the reference that is passed to draw() as its only

parameter at runtime will be one to a Graphics2D object, the parameter of draw() is actually only

declared as being of type Graphics, so you will need to typecast the parameter to a Graphics2D

object inside the method if you wish to use methods that are not already inherited from Graphics. You

will need to override this method in every shape subclass you create, and ensure that the respective

shape gets drawn properly. You should find the API documentation of the Graphics2D class useful:

https://docs.oracle.com/javase/10/docs/api/java/awt/Graphics2D.html

? contains(): This method takes a Point parameter and is meant to return true if the Point is inside

the shape and false if it is not. Since you will be creating different shapes, you will need to override

this method for each shape that has a new outline, unless it makes sense to simply inherit it from an

ancestor class with the same outline.

Once you have created a new shape subclass, you will need to add it to AnimationPanel.java. The

createNewShape() method in line 67 of AnimationPanel.java is the place to do this. You’ll notice a

switch statement that is currently commented out. Uncomment it, and it provides you with the code required to

integrate your first subclass (the MovingRectangle class from Stage 1 below). Adding further shapes here

should be as easy as adding further case clauses. OK, you’re now ready to start!

You must include your name, UPI and a comment at the beginning of each file you create or modify.

Stage 1: The MovingRectangle class (8 marks)

You are required to add a MovingRectangle subclass to your program. This class must draw a

rectangle/square based on the mouse point, size, the current border colour, the current fill colour and, the current

moving path saved in the AnimationPanel. Two examples are shown below:

COMPSCI 230 S2 - Assignment 01

3

Assessment criteria:

? [2 marks] The class hierarchy must be developed sensibly and in accordance with good object‐oriented

programming practice.

? [2 marks] The draw method is overridden correctly

? [2 marks] The contains method is overridden correctly

? [1 mark] Users must be able to create a new rectangle using the current fill and border colours, height,

width and path in the program.

? [1 mark] Users must be able to change the fill and border colours, width, height and bouncing path of

selected rectangles.

Stage 2: The MovingOval class (8 marks)

You are required to add a MovingOval subclass to your program. This class must draw a circle/ellipse based on

the mouse-point, the current width, the current height, the current border colour, the current fill colour, and the

current moving path saved in the AnimationPanel. Two examples are shown below:

Note: You may use the following formula to check if the mouse point is clicked within a circle/ellipse.

Point EndPt = new Point(topLeft.x + width, topLeft.y + height);

dx = (2 * mousePt.x - topLeft.x - EndPt.x) / (double) width;

dy = (2 * mousePt.y - topLeft.y - EndPt.y) / (double) height;

return dx * dx + dy * dy < 1.0;

Assessment criteria:

? [2 marks] The class hierarchy must be developed sensibly and in accordance with good object‐oriented

programming practice.

? [2 marks] The draw method is overridden correctly

? [2 marks] The contains method is overridden correctly

? [1 mark] Users must be able to create a new oval using the current fill and border colours, height, width

and path in the program.

? [1 mark] Users must be able to change the fill and border colours, width, height and bouncing path of

selected ovals.

Stage 3: The MovingChecker class (14 marks)

You are required to add a MovingChecker subclass to your program. This class must draw a checker pattern

based on the mouse-point, the current width, the current height, the current border colour, the current fill colour,

and the current moving path saved in the AnimationPanel. Two examples are shown below:

(Fill: blue, Border: black) (Fill: green, Border: blue)

Assessment criteria:

? [3 marks] The class hierarchy must be developed sensibly and in accordance with good object‐oriented

programming practice. Do you need to override the draw() and / or contains() methods?

? [4 marks] The subclass must contain two variables to store the number of blocks horizontally and

vertically. For example, there are 8 x 8 blocks in the first image and 5 x 5 blocks in the second image

above. Their values must be set as random numbers between 2 and 7 (inclusive) in the constructor.

COMPSCI 230 S2 - Assignment 01

4

? [4 marks] Users must be able to create a new checker pattern using the current fill (first) and border

(second) colours, height, width and path in the program.

? [3 marks] Users must be able to change the fill and border colours, width, height and bouncing path of

selected patterns.

Stage 4: The MovingGradient class (12 marks)

You are required to add a MovingGradient subclass to your program. You are now required to get creative and

add your own gradient pattern that will make the bouncing program more interesting! This class should draw a

gradient-rectangle based on the mouse-point, the current width, the current height, the current border colour, the

current fill colour, and the current moving path saved in the AnimationPanel. Some examples are shown

below:

(Fill: red, border: blue/yellow)

Assessment criteria:

? [3 marks] The class hierarchy should be developed sensibly and in accordance with good

object‐oriented programming practice. Do you need to override the draw and/or contains?

? [4 marks] Users must be able to create a new gradient pattern using the current fill (first) and border

(second) colours, height, width and path in the program.

? [2 marks] Users must be able to change the fill and border colours, width, height and bouncing path of

selected patterns.

? [3 marks] In the marker’s opinion, your work shows great preparation, creativity or effort.

Stage 5: The MovingShapePattern class (12 marks)

You are required to add a MovingShapePattern subclass to your program. You are now required to get

creative and add your own pattern that will make the bouncing program more interesting! This class should draw

a pattern based on the mouse-point, the current width, the current height, the current border colour, and the

current moving path saved in the AnimationPanel. Some examples are shown below:


Assessment criteria:

? [3 marks] The class hierarchy must be developed sensibly and in accordance with good object‐oriented

programming practice. Do you need to override the draw and/or contains?

? [4 marks] Users must be able to create a new shape pattern using the current border colour (fill color is

not required but allowed), height, width and path in the program.

? [2 marks] Users must be able to change the border colour, width, height and bouncing path of selected

patterns.

? [3 marks] In the marker’s opinion, your work shows great preparation, creativity or effort.

Stage 6: Adding a new path (6 marks)

In this part, you are required to add your own designed path to the bouncing program. The MovingPath is an

abstract inner class which contains an abstract method. You are required to add a new subclass which extends

the MovingPath and implement the move() method.

Lines 73-75 of A1.java show you how the current two path icons are integrated into the combo box for the

path. You will need to add your own path here, and create your own icon as a .gif file.

COMPSCI 230 S2 - Assignment 01

5

Assessment criteria

? [1 mark] The class hierarchy must be developed sensibly and in accordance with good object‐oriented

programming practice.

? [3 marks] Users must be able to add a new shape using your own designed path.

? [2 marks] Users must be able to change the bouncing path of selected shapes to your own designed path.

Submission

Submit your assignment online via the assignment dropbox (https://adb.auckland.ac.nz/) at any time from the

first submission date up until the final date. You will receive an electronic receipt.

Submit ONE A1.zip file containing all the following files:

1. All source files (i.e. new, changed, and unchanged) – remember to include your name, UPI and a

comment at the beginning of each file you create or modify.

2. All gif files (used as icons in the program)

3. A1.txt

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 and A1.txt (see

below) in the zip file before you submit it. Your program must compile and run to attract any marks. We

recommend that you check this on the lab machines before you submit.

What to include inside the A1.txt file

You must include a text file named A1.txt in your submission. This text file must contain the following

information:

? Your name, login name (such as jlim123) and (7 or 9 digit) ID number

? How much time did the assignment take you overall?

? Which areas of the assignment did you find easy and which ones were difficult?

? Which topics in the course did the assignment most help you understand?

? Any other comments you would like to make.

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 acceptable:

? Lecture notes, tutorial notes, skeleton code, and advice given by us in person or online, with the

exception of sample solutions from past semesters.

? The textbook.

? The official Java documentation and other online sources, as long as these describe the general use of

the methods and techniques required, and do not describe solutions specifically for this assignment.

? Piazza posts by, or endorsed by an instructor.

? Fellow students pointing out the cause of errors in your code, without providing an explicit solution.

The following sources of help are not acceptable:

? Getting another student, friend, 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 else’s 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:

o Always do individual assignments by yourself.

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

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

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

o Ensure you always remove your USB flash drive from the computer before you log off, and

keep it safe.


版权所有:留学生程序网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。