Results 1 to 1 of 1
Thread: Bluej Hangman Game Help
- 03-29-2011, 10:14 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
Bluej Hangman Game Help
Hey I am fairly new at this and was hoping to get some help on this assignment. For my next part of the project, I have to make a HangmanGame class which displays both my Person class and the background class (which is titled MyPicture). How would I go about making both of these visible in my new HangmanGame class? Is there any easier way of making the Person & background show without having to just copy & paste everything in these classes? Any hints, tips, comments would be greatly appreciated. Thanks.
public class Person
{
// instance variables - replace the example below with your own
private Ellipse head;
private Rect body;
private Rect arm;
private Rect arm2;
private Rect leg;
private Rect leg2;
private int count;
private boolean isVisible;
private int xPosition;
private int yPosition;
/**
* Constructor for objects of class Person
*/
public Person()
{
isVisible = false;
count = 6;
xPosition=0;
yPosition=0;
}
public void setPosition(int newXPosition, int newYPosition)
{
head.setPosition(newXPosition+50, newYPosition+50);
body.setPosition(newXPosition+53, newYPosition+101);
arm.setPosition(newXPosition+40, newYPosition+101);
arm2.setPosition(newXPosition+94, newYPosition+101);
leg.setPosition(newXPosition+53, newYPosition+171);
leg2.setPosition(newXPosition+78, newYPosition+171);
}
/**
* Make this picture visible.
*/
public void makeVisible()
{
head = new Ellipse();
head.moveHorizontal(50);
head.moveVertical(50);
head.makeVisible();
head.changeColor("black");
body = new Rect();
body.moveHorizontal(53);
body.moveVertical(101);
body.makeVisible();
body.changeColor("black");
arm = new Rect();
arm.changeSize(12, 70);
arm.moveHorizontal(40);
arm.moveVertical(101);
arm.makeVisible();
arm.changeColor("black");
arm2 = new Rect();
arm2.changeSize(12, 70);
arm2.moveHorizontal(94);
arm2.moveVertical(101);
arm2.makeVisible();
arm2.changeColor("black");
leg = new Rect();
leg.makeVisible();
leg.changeSize(15, 70);
leg.moveHorizontal(53);
leg.moveVertical(171);
leg.changeColor("black");
leg2 = new Rect();
leg2.makeVisible();
leg2.changeSize(15, 70);
leg2.moveHorizontal(78);
leg2.moveVertical(171);
leg2.changeColor("black");
}
public int getNumLeft ()
{
return count;
}
public void reset ()
{
head.makeInvisible();
isVisible=false;
body.makeInvisible();
isVisible=false;
arm.makeInvisible();
isVisible=false;
arm2.makeInvisible();
isVisible=false;
leg.makeInvisible();
isVisible=false;
leg2.makeInvisible();
isVisible=false;
count=6;
}
public void showNext()
{
if (head.isVisible != true)
{
head.makeVisible();
count--;
}
else if (body.isVisible != true)
{
body.makeVisible();
count--;
}
else if (arm.isVisible != true)
{
arm.makeVisible();
count--;
}
else if (arm2.isVisible != true)
{
arm2.makeVisible();
count--;
}
else if (leg.isVisible != true)
{
leg.makeVisible();
count--;
}
else if (leg2.isVisible != true)
{
leg2.makeVisible();
count--;
}
}
}
public class MyPicture
{
private Rect2 gallow;
private Rect gallow2;
private Rect2 gallow3;
private Rect gallow4;
private Rect gallow5;
private Rect2 gallow6;
private Rect gallow7;
private Rect gallow8;
/**
* Constructor for objects of class Picture
*/
public MyPicture()
{
// nothing to do... instance variables are automatically set to null
}
/**
* Draw this picture.
*/
public void draw()
{
gallow = new Rect2();
gallow.moveVertical(280);
gallow.moveHorizontal(0);
gallow.changeColor("black");
gallow.makeVisible();
gallow2 = new Rect();
gallow2.moveVertical(210);
gallow2.moveHorizontal(0);
gallow2.changeColor("black");
gallow2.changeSize(20, 70);
gallow2.makeVisible();
gallow3 = new Rect2();
gallow3.moveVertical(0);
gallow3.moveHorizontal(0);
gallow3.changeColor("black");
gallow3.makeVisible();
gallow4 = new Rect();
gallow4.moveVertical(0);
gallow4.moveHorizontal(65);
gallow4.makeVisible();
gallow4.changeColor("black");
gallow4.changeSize(20,50);
gallow5 = new Rect();
gallow5.moveVertical(140);
gallow5.moveHorizontal(0);
gallow5.changeColor("black");
gallow5.changeSize(20, 70);
gallow5.makeVisible();
gallow6 = new Rect2();
gallow6.moveVertical(280);
gallow6.moveHorizontal(70);
gallow6.changeColor("black");
gallow6.makeVisible();
gallow7 = new Rect();
gallow7.moveVertical(70);
gallow7.moveHorizontal(0);
gallow7.changeSize(20, 70);
gallow7.makeVisible();
gallow7.changeColor("black");
gallow8 = new Rect();
gallow8.moveVertical(0);
gallow8.moveHorizontal(0);
gallow8.changeSize(20, 70);
gallow8.changeColor("black");
gallow8.makeVisible();
}
Similar Threads
-
Hangman Game
By getshum in forum New To JavaReplies: 1Last Post: 02-26-2011, 04:01 AM -
Hangman Game // HELP //
By K-Scale in forum New To JavaReplies: 4Last Post: 05-27-2010, 12:01 AM -
Hangman Game Help Please
By 9tjh in forum New To JavaReplies: 4Last Post: 12-04-2009, 03:19 AM -
Hangman Game..
By iPetey in forum New To JavaReplies: 4Last Post: 05-07-2009, 02:24 PM -
Need help with hangman game
By kurt in forum New To JavaReplies: 4Last Post: 04-25-2009, 06:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks