首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导ITI 1121编程语言、讲解Java,C++程序设计 讲解SPSS|解析Java程序
项目预算:
开发周期:
发布时间:
要求地区:
ITI 1121. Introduction to Computing II
Assignment 2
Submission deadline: See Brightpsace
Assignment: Group of 2 students Maximum.
All the rules of the first assignment apply.
Reminders: The submitted code must be yours.
You are also responsible to not expose your code to others.
The submission must be done on Brightspace, before the deadline.
- Only submit your java files, do not submit any .class files.
- You must test your programs to make sure they give the correct results.
- A program that gives a compilation error or an execution error will receive a mark of zero.
- You have to put comments in the programs. The comments are not needed for each line of
code. However, they have to explain in simple English what the program does.
- Some java files are provided, they should be used and the content already there cannot be
modified. Which means you need to keep the existing code and add your code to it.
- Important: one submission per group is enough, however both students are responsible to make
sure the submission was done before the deadline.
Academic Integrity
https://www.uottawa.ca/administration-and-governance/academic-regulation-14-other-important-information
https://www.uottawa.ca/vice-president-academic/academic-integrity
By submitting this assignment, you acknowledge the following:
1. I have read the academic regulations of the University of Ottawa regarding academic fraud.
2. I understand the consequences of plagiarism.
3. With the exception of the source code provided by the professor for this course, all the source code is mine and
my group partner only.
ITI 1121. Introduction to Computing II
In this assignment, you will program a game, “Catch the mouse” with a simple user interface.
The game’s user interface shows a board, made of a cubes, with the same number of rows and
columns. The board contains grey (free) cubes, green (snakes) cubes, and one red (mouse) cube.
The player tries to catch the red mouse before it reaches the edge. If the mouse (red cube) reaches
the edge, the player loses. If the player clicks any square, there are four cases:
- If the square is already a green cube (a snake) nothing happens.
- If it is a square that is a neighbor of another snake, it turns into a snake too.
- If it is a square that is not a neighbor of any other snake, nothing happens.
- If it is a red cube (a mouse) and it is currently next to any snake, the game is won.
Note: a position is a “neighbor” of another one if we can go from the first position to the second
in a single move, without skipping any cube.
The mouse cannot move to any of the squares already clicked by the user, which turn into snakes.
If the player clicks it before it reaches the edge, then player wins!
The image below is an example of the game starting screen.
The number of rows is equal to the number of columns.
The player wins when he can click on the red cube (the mouse). It can only be clicked if it is
neighboring one of the green cubes (it is reached by the snake).
If the
At the start of the game, some of the cubes are already green. This is done with a random selection
among all the board cubes. The maximum number of green cubes allowed is a constant number of
five: 5. All other cubes will initially be free cubes, and one cube red.
The starting position of the red mouse is semi-randomly selected: which means random however
it should be close to the center of the board. Here is the procedure to select starting red mouse
position:
- If the board has an even number of rows (and columns), then the red cube is randomly positioned
on one of the central four cubes.
- If the number of rows (and columns) is odd, then it is randomly positioned on one of the central
nine cubes.
ITI 1121. Introduction to Computing II
At each step the player can only select one of the six neighboring cubes of an already selected cube
(green snakes cubes).
The player wins when the red cube is clicked on while neighboring a green cube.
However, if the red mouse is clicked while no green snake cube is its neighbor, then nothing
happens.
The roles of the classes is different, basically we have three categories:
I- The state of the game at any given moment in time
II- The user interface
III- The processing/logic of the game
I- The Game State (30 points)
First, build the state of the game using the class GameState and the class Point. There is only one
instance of the class GameState (instantiated by GameLogic as we will specify later).
GameState is responsible for holding the state of the game at any moment in time. This includes
- The three possibilities for each square in the game board:
1- It is free: the cube occupying it is grey, it hasn’t been selected yet by the player
2- It is already selected: the cube occupying it is a green snake
3- It is occupied by the red mouse cube
- The location of the red mouse cube: The starting location of the red cube, as explained earlier:
on an even board, the position is randomly selected among the four central cubes, and on an
odd board, it is randomly selected among the nine central locations.
- The current status of every cube on the board
- The size of the board.
It also provides the necessary setters and getters, so the the GameLogic and the user interface can
check the status of any cube, and the GameLogic can change the status of a cube or move the red
mouse cube. Finally, it provides a way to initialize the game, placing the red cube randomly as
explained earlier, and preselecting some of the other cubes as green snake cubes. In our case, we
are going to use 10% as the probability that a cube that isn’t the red cube is initially selected as a
snake cube.
ITI 1121. Introduction to Computing II
II- The User Interface (35 points)
We build a simple User Interface for the game. This will be done with two classes.
- The first class is GameUserInterface, which extends JFrame. It is the main window of the
application. It shows two buttons at the bottom (see the image in the first page). These
buttons are to reset and to quit the game. GameUserInterface instantiates the second class,
BoardUserInterface.
- The second class is BoarUserInterface, it extends JPanel. This class is the one that contains
the board.
A board, of size n, is made of a series of cubes: n lines and n columns of cubes.
To implement the cubes, we use the class Cube which extends the class JButton.
So the class BoardUserInterface provides the user interface of the board. It extends JPanel
and lays out a two dimensional array of Cube instances.
Layout of the game board.
A challenging aspect of the User Interface is the layout of the board. If the board was a normal
square, it you be really easy to layout the Cube instances on the Panel. However, the actual board
of the game is not a perfect square. Instead, each line is shifted left or right when compared to the
previous line. Your board layout should look like the one in the image shown on the first page. We
don’t have a way to create that Layout directly.
In order to achieve this layout, we will use two steps within BoarUserInterface:
1- We will have each row of Cube instances on its own instance of a JPanel class, on which a
FlowLayout manager will be used. If you look at the documentation of JPanel, you will see
that it is possible to add a border to the panel.
The icons used by the Cube instances are squares of size 40 pixels. So we can add a border of
size 20 for example, at the correct location, to obtain the desired layout.
2- The set of JPanels can then be added on the BoarUserInterface JPanel using for example an
appropriate GridLayout manager.
Note: instances of both GameUserInterface and BoarUserInterface classes have buttons. However,
these instances are not the listeners for the events generated by these buttons. This is handled by
the gameLogic.
ITI 1121. Introduction to Computing II
III- The GameLogic (35 points)
The class GameLogic is the one responsible for the logic/processing of the game. The constructor
of the class receives as parameter the size of the board.
The instance of the GameState and the GameUserInterface are created in this class.
The GameLogic is the class handling the events/clicks generated by the player. It implements the
logic of the game. During the game, after the player selects a new cube, the GameLogic must
decide what to do next.
After each click of the player, the three cases need to be covered: the player won the game, the
player lost the game, or the game continues.
If the player won: a message box should be displayed to inform the player, when the player clicks
“ok”, the game is reset.
If the player lost: a message should be displayed accordingly.
The green snake cubes areas grows one cube at a time, in one of the six cubes that surround a green
snake cube.
Cases of winning or losing the game.
In the two cases, the GameLogic must inform the player of the result. In order to achieve this, the
gameLogic can use the class method showMessageDialog of the class JOptionPane.
To continue the game, the gameLogic must implement a strategy for a selection of the next move
for the red cube.
You may make a selection to move the red cube to any randomly selected cube that is not occupied
by a green cube. If the red mouse reaches the edge, the player lost.
CubesGame.java is the java class containing the main program to start the game.
CubesGame creates the instance of GameLogic and starts the game. CubesGame is the class that
contains the main and should be run by the user. At the execution of the game, the user should
pass a parameter to main. This parameter is the size of the game board. This size is valid if it is
between 4 and 20. If a valid size is not passed, an error message is simply displayed, and the user
should try to run the program again with the correct parameter.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!