辅导ITI 1121程序、 写作java编程

” 辅导ITI 1121程序、 写作java编程ITI 1121. Introduction to Computing IIAssignment 2Submission deadline: See BrightpsaceAssignment: 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 ofcode. 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 bemodified. 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 makesure the submission was done before the deadline.Academic Integrity httpss://www.uottawa.ca/administration-and-governance/academic-regulation-14-other-important-information httpss://www.uottawa.ca/vice-president-academic/academic-integrityBy 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 andmy group partner only.ITI 1121. Introduction to Computing IIIn this assignment, you will program a game, Catch the mouse with a simple user interface.The games user interface shows a board, made of a cubes, with the same number of rows andcolumns. 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) reachesthe 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 secondin 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 isneighboring one of the green cubes (it is reached by the snake).If theAt the start of the game, some of the cubes are already green. This is done with a random selectionamong all the board cubes. The maximum number of green cubes allowed is a constant number offive: 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 howeverit should be close to the center of the board. Here is the procedure to select starting red mouseposition:- If the board has an even number of rows (and columns), then the red cube is randomly positionedon one of the central four cubes.- If the number of rows (and columns) is odd, then it is randomly positioned on one of the centralnine cubes.ITI 1121. Introduction to Computing IIAt 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 nothinghappens.The roles of the classes is different, basically we have three categories:I- The state of the game at any given moment in timeII- The user interfaceIII- The processing/logic of the gameI- The Game State (30 points)First, build the state of the game using the class GameState and the class Point. There is only oneinstance 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 hasnt been selected yet by the player2- It is already selected: the cube occupying it is a green snake3- 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 anodd 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 cancheck the status of any Cube, and the GameLogic can change the status of a cube or move the redmouse cube. Finally, it provides a way to initialize the game, placing the red cube randomly asexplained earlier, and preselecting some of the other cubes as green snake cubes. In our case, weare going to use 10% as the probability that a cube that isnt the red cube is initially selected as asnake cube.ITI 1121. Introduction to Computing IIII- 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 theapplication. It shows two buttons at the bottom (see the image in the first page). Thesebuttons 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 containsthe 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 JPaneland 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 normalsquare, it you be really easy to layout the Cube instances on the Panel. However, the actual boardof the game is not a perfect square. Instead, each line is shifted left or right when compared to theprevious line. Your board layout should look like the one in the image shown on the first page. Wedont 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 aFlowLayout manager will be used. If you look at the documentation of JPanel, you will seethat 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 ofsize 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 anappropriate 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 bythe gameLogic.ITI 1121. Introduction to Computing IIIII- The GameLogic (35 points)The class GameLogic is the one responsible for the logic/processing of the game. The constructorof 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 thelogic of the game. During the game, after the player selects a new cube, the GameLogic mustdecide what to do next.After each click of the player, the three cases need to be covered: the player won the game, theplayer lost the game, or the Game continues.If the player won: a message box should be displayed to inform the player, when the player clicksok, 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 greensnake 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, thegameLogic 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 movefor the red cube.You may make a selection to move the red cube to any randomly selected cube that is not occupiedby 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 thatcontains the main and should be run by the user. At the execution of the game, the user shouldpass a parameter to main. This parameter is the size of the game board. This size is valid if it isbetween 4 and 20. If a valid size is not passed, an error message is simply displayed, and the usershould try to run the program again with the correct parameter.请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导