Build the gui layout of the gamecreate a class called

beplay体育怎么安装JAVA Programming
Reference no: EM13346889

Build the GUI layout of the game

Create a class called PipeGameApp.java which will be the main game user interface. The interface should have the title "The Frantic Pipe Layer" and contain an 11x11 grid of 40pixel x 40pixel buttons as shown below. The buttons should be arranged on a BoardPanel (which is a subclass of JPanel that you can download along with this assignment in the BoardPanel.java file). The BoardPanel ensures that the size of the buttons do not change. Make sure that your window opens with all buttons enabled and not selected.

2009_build gui gui布局.png

工作按钮

PipeGame类代表实际的游戏out the graphical user interface. The idea is that the game stores a grid of pipe shapes that are placed onto it. The user will be able to click on any unoccupied grid locations to place a pipe piece down. The very first pipe piece that must be placed is the valve pipe shown here to the right. All other pipe pieces must be non-valve pipes and may be one of the following:

627_build guam gui布局1.png

Also note that the valve pipe is a special one and is called pipesStart.GIF.

当游戏运行时,光标应始终显示用户可能放置的下一个(即当前的)管道,以便用户在将管道放下之前先查看管道。PipeGame类中的GetNextPipe()方法返回要放置的下一个管道。然后,您可以为该管道创建一个图像图标,如下所示:

ImageIcon i;
if (game.getNextPipe().isValve())

else
i = new ImageIcon("pipesStart.GIF");
i = new ImageIcon("pipes"+ game.getNextPipe().toString() +".GIF");

Then you can use the following code to change the cursor into any given pipe picture (assuming that tiles is the BoardPanel object that contains the buttons):

tiles.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(i.getImage(),
new Point(0,0), "pipe"));

Then to return the cursor to normal, you can just use:

tiles.setCursor(Cursor.getDefaultCursor());

将适当的事件处理程序添加到按钮中,以便用户单击按钮时,将管道放在该位置。为此,您只需要存储该按钮的图像即可。在Java中,您可以通过设置按钮的“选定图标”来执行此操作:如下:
String currentPipeCodes = game.getNextPipe().toString();
Abutton.setSelectedicon(新Imageicon(“ Pipes” + CurrentPipeCodes +“ .gif”));
aButton.setSelected(true);

请记住,第一个管道(即阀管)是使用“ pipesstart.gif”文件的特殊情况。放置任何管道后,将使用新的随机管道用作下一个要放置的管道。调整管道类中的静态随机()方法,以返回随机管道零件(即,在4个方向上具有随机开口的新管道),而不是每次同一件。确保您的代码有效。

查看管道类别,因为它已经保持了跟踪管道对象的2维网格的属性,到目前为止,已放置在网格上的管道数量以及将放置下一个管道。一种称为resetpipes()的实例方法将网格重置,因此网格中的所有管道都开始为无效,下一个要放置的管道是阀管。

在继续之前,请确保您可以在整个网格上放置大量管道。

(3) Smart Pipe Placement

Now you will adjust your code so that pipes can only be placed on a grid location if the pipe actually fits with the (up to) 4 pipes around it. Also, once a pipe has been placed at a location, no other pipe can be placed there.

每个管道都以1,2,3或4个方向开放。末端碎片显示为红色圆圈。

管道存储4个布尔值,指示管道在顶部,右,底部还是左的顶部,右,底部或左开放,表明它是阀门是否是阀门(设置为上述所有15个零件的false)。

Instance methods fitsBelow(Pipe p), fitsAbove(Pipe p), fitsToLeftOf(Pipe p), and fitsToRightOf(Pipe p) return a boolean indicating whether or not the receiver pipe fits below, above, to the left of or to the right of the given pipe p, respectively. Note that two pipes "fit" together if they both have openings that meet when placed beside each other or both do NOT have openings.

Here are examples of pipes that "fit" beside one another:

1972_Build the GUI layout of the game2.png

Here are examples of Pipes that DO NOT "fit" beside one another:

1760_Build the GUI layout of the game3.png

修改称为plandpipe(int Row,int col)的实例方法,该方法试图将当前管道放置在指定的网格位置。目前,无论是否正确安装管道,管道始终都放置。调整代码,以便如果管道不适合那里,则返回false,否则将返回true。同样,如果管道拟合在此位置,则将放置管道的数量增加,并选择一个随机选择的新管道作为下一个要放置的管道(而不是阀门,因为只有一个阀门)。下一页显示了一段时间后的有效板。确保还要输入所有管道图片文件,因为它们需要运行代码。

2225_build gui 4.png的GUI布局

Reference no: EM13346889

Previous Q& A

使用3个月的商业贷款提供了2000万个商业贷款

使用3个月LIBOR INDEX100BP提供了2000万个商业贷款。经过一些初步研究,使用

Analyze the processed data in statistical survey below are

analyze the processed data in statistical survey. below are the results of the processed data.question 1 yes p 0.1986

关于简单数据分析的报告,并

在简单的数据分析和比较上写一份报告。简要说明您要使用的简单数据分析方法

1 the economy cant be considered fully employed unless the

1 the economy cant be considered fully employed unless the measured unemployment rate is below 1. agree or disagree and

Pest analysis of accor gropup of hotelsthe focus

pest analysis of accor gropup of hotelsthe focus synthesises current strategic practices and should take the format of

1可以考虑这个逻辑回归模型model

model 1nbsp lets consider the logistic regression model which we will refer to as model 1 given

A new oncologist has joined the medical staff since 4 west

一位新的肿瘤学家加入了医务人员。由于4 West一直是肿瘤患者的录取单位

Hon-a-chipnbsp microfluidics-based devices for

基于人类的chipnbsp微流体设备,用于模拟单个器官或器官的生理学

To increase the awareness of monitoring and recording the

to increase the awareness of monitoring and recording the blood pressure of patientsto practice measuring blood

准备一个或两种新产品的营销计划

prepare a marketing plan for one or two new products in your own business andor another business in your country or

Reviews

写评论

Similar Q& A

班级图表示父母之间的关系

Draw a class diagram that represents the relationship between parents, children, and grandparents. Take into account that a person can have both a parent and a child. Annotate associations with roles and multiplicities.

Write a void function this passed three integers

1. Write a void function this passed three integers by reference. The function should rearrange the parameter values so that the first parameter will get the smallest value; the second parameter the middle value; and the third parameter the largest v..

The program randomly generates the quiz question one by

该程序随机从一组可用的问题中逐一生成测验问题

Have to implement a search algorithm

Suppose you have to implement a search algorithm in a high programming language such as Java or C++. You are given a linked list that is not sorted and it's rather small, in the order of a few dozen elements.

Teaching software componentization

Describe one way in which one could apply Java graphics in education. Provide one example of such use to support your response and analyze at least three commands that you would use in order to draw a bar chart. Provide a rationale for your respons..

Java program that reads an input

Create a java program that reads an input of n lines with the first line being the number of people in the contest and the remaining lines a numeric 9 digit code for each person that gets a vote

Test plan for both unit testing and integration testing

Do a test plan for both unit testing and integration testing, justification why you need this test creating the test case for each individual test must use java language in netbeans IDE to perform each test, screen capture one example to run the ..

Develop java applet that will help elementary school student

Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce two positive one-digit integers.

Creates an array named odds

Write code that creates an array named odds and stores all odd numbers between -6 and 38 into it using a loop. Make the array's size exactly large enough to store the numbers.

开发实施文件student.cpp

Required to implement the class to develop the implementation file Student.cpp that conforms to the following specifications

Javascript validation - cgi program

CGI mailer script form-mail.pl to your server's cgi-bin directory, and change the permissions on the script to make it executable - BMIS 310

Write a java program that asks the user for his/her gender

According to researchers at Stanford Medical School, the ideal weight for a woman is found by multiplying her height in inches by 3.5 and subtracting 108.

Free Assignment Quote

Assured A++ Grade

在您与我们付款的每个任务订单中获得保证满意度和交货时间!我们确保高级质量解决方案文档以及免费的Turntin报告!

beplay安卓下载

Baidu