i need to convert this JApplet program into a JFrame, but dont know how to do it, can anybody help me please? [this is extremly urgent as i need to have this done by tuesday]
/*Game.java
5.5.08
This program, Game.java, is an educational game that tries to allow the user to
have fun while learning at the same time. My game is Monta Vista Monopoly. The
idea is monopoly but the location is our good home, Monta Vista! My first panel
asks the users to enter their names. Then they choose their character. The user
may choose characters from the game Super Smash Bros. Brawl. The choices are
Pokemon Trainer, Pikachu, Link, and Zelda. The user clicks on a picture of the
character they want and the sprite, or animated/miniature version, of that char
is placed on the monopoly board. And then the game begins! The monopoly board
is a regular ten by ten monopoly board. All the houses/properties have been
edited on paint.net and have ben changed so that they show places in monta vista
There are four different buttons.
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Game extends JApplet {
//data members
private int xpos1;
private int xpos2;
private int ypos1;
private int ypos2;
private String p1;
private String p2;
private JButton go;
private Container c;
private int p1money;
private int p2money;
private int p1posit;
private int p2posit;
private int [] price;
private String p1char;
private String p2char;
private String player;
private boolean rolled;
private int [] location;
private JPanel entername;
private JPanel boardgame;
private CardLayout cards;
private Image introtopsc;
private Image endedtopsc;
private Image zeldmainpc;
private Image zeldsprite;
private Image linkmainpc;
private Image linksprite;
private Image pokemainpc;
private Image pokesprite;
private Image pikamainpc;
private Image pikasprite;
private Cha1Panel chooseone;
private Cha2Panel choosetwo;
private WinnPanel winnpanel;
private Image monopolyboard;
private boolean [] property1;
private boolean [] property2;
private JTextField p1nametext;
private JTextField p2nametext;
//constructors
public Game( ) {
xpos1 = 585;
ypos1 = 585;
xpos2 = 585;
ypos2 = 585;
p1posit = 1;
p2posit = 1;
p1money = 1000;
p2money = 1000;
rolled = false;
price = new int [45];
location = new int [45];
p1char = new String("");
p2char = new String("");
property1 = new boolean [45];
property2 = new boolean [45];
for (int i = 0; i < 45; i++) {
property1[i] = false;
property2[i] = false;
}
price[1] = 0;
price[2] = 60;
price[3] = 0;
price[4] = 60;
price[5] = 0;
price[6] = 200;
price[7] = 110;
price[8] = 0;
price[9] = 110;
price[10] = 120;
price[11] = 0;
price[12] = 140;
price[13] = 140;
price[14] = 140;
price[15] = 160;
price[16] = 200;
price[17] = 160;
price[18] = 0;
price[19] = 160;
price[20] = 160;
price[21] = 0;
price[22] = 220;
price[23] = 0;
price[24] = 220;
price[25] = 220;
price[26] = 200;
price[27] = 260;
price[28] = 260;
price[29] = 140;
price[30] = 260;
price[31] = 0;
price[32] = 300;
price[33] = 300;
price[34] = 0;
price[35] = 320;
price[36] = 200;
price[37] = 0;
price[38] = 360;
price[39] = 0;
price[40] = 400;
}
public void init( ) {
c = this.getContentPane( );
cards = new CardLayout( );
c.setLayout(cards);
entername = new MainPanel( );
chooseone = new Cha1Panel( );
choosetwo = new Cha2Panel( );
boardgame = new BoardGame( );
winnpanel = new WinnPanel( );
c.add(entername, "Greeting");
c.add(chooseone, "Choose avatar player 1");
c.add(choosetwo, "Choose avatar player 2");
c.add(boardgame, "Monta Vista Monopoly" );
c.add(winnpanel, "The Winnter is:" );
zeldmainpc = getImage( getDocumentBase( ), "zelm.jpg" );
WaitForImage(this,zeldmainpc);
zeldsprite = getImage( getDocumentBase( ), "zels.jpg" );
WaitForImage(this,zeldsprite);
linkmainpc = getImage( getDocumentBase( ), "linm.jpg" );
WaitForImage(this,linkmainpc);
linksprite = getImage( getDocumentBase( ), "lins.jpg" );
WaitForImage(this,linksprite);
pokemainpc = getImage( getDocumentBase( ), "pokm.jpg" );
WaitForImage(this,pokemainpc);
pokesprite = getImage( getDocumentBase( ), "poks.gif" );
WaitForImage(this,pokesprite);
pikamainpc = getImage( getDocumentBase( ), "pikm.jpg" );
WaitForImage(this,pikamainpc);
pikasprite = getImage( getDocumentBase( ), "piks.jpg" );
WaitForImage(this,pikasprite);
introtopsc = getImage( getDocumentBase( ), "monopoly.jpg");
WaitForImage(this,introtopsc);
endedtopsc = getImage( getDocumentBase( ), "endedtopsc.jpg");
WaitForImage(this,endedtopsc);
monopolyboard = getImage( getDocumentBase( ), "mono.jpg" );
WaitForImage(this,monopolyboard);
}
public void WaitForImage(JApplet component,Image image) {
MediaTracker tracker = new MediaTracker( component );
try {
tracker.addImage( image, 0 );
tracker.waitForID( 0 );
}
catch ( InterruptedException e ) {
e.printStackTrace( );
}
}
public Insets getInsets( ) {
return new Insets(0,0,0,0);
}
class MainPanel extends JPanel implements ActionListener {
private JLabel greeting;
private JLabel p1name;
private JLabel p2name;
public MainPanel( ) {
setLayout(new GridLayout(6, 1));
greeting = new JLabel("", JLabel.CENTER);
this.add(greeting);
p1name = new JLabel("");
this.add(p1name);
p1nametext = new JTextField(10);
this.add(p1nametext);
p2name = new JLabel("");
this.add(p2name);
p2nametext = new JTextField(10);
this.add(p2nametext);
go = new JButton("GO!");
go.addActionListener ( this );
this.add(go);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(introtopsc,0,0,this);
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ( command.equals("GO!")) {
p1 = new String(p1nametext.getText( ));
chooseone.p1request.setText(p1+ " choose your character [click on the picture]");
p2 = new String(p2nametext.getText( ));
choosetwo.p2request.setText(p2+ " choose your character [click on the picture]");
cards.next(c);
}
}
}
class Cha1Panel extends JPanel implements MouseListener {
private int xpos;
private int ypos;
public JLabel p1request;
public Cha1Panel( ) {
setLayout(new FlowLayout( ));
p1request = new JLabel( p1 + " choose your character [click on the the picture]");
this.add(p1request);
addMouseListener(this);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(zeldmainpc,163,110, this);
g.drawImage(linkmainpc,602,110, this);
g.drawImage(pokemainpc,163,385, this);
g.drawImage(pikamainpc,602,385, this);
}
public void mousePressed(MouseEvent evt) { }
public void mouseEntered(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
public void mouseReleased(MouseEvent evt) { }
public void mouseClicked(MouseEvent evt) {
xpos = evt.getX();
ypos = evt.getY();
if (xpos>=163 && xpos<=497) {
if (ypos>=110 && ypos<=275) {
p1char = "zeld";
}
if (ypos>= 285 && ypos<=560) {
p1char = "link";
}
}
if (xpos<=602 && xpos <= 836) {
if (ypos>=110 && ypos<=275) {
p1char = "poke";
}
if (ypos>= 285 && ypos<=560) {
p1char = "pika";
}
}
cards.next(c);
repaint( );
}
}
class Cha2Panel extends JPanel implements MouseListener {
private int xpos;
private int ypos;
public JLabel p2request;
public Cha2Panel( ) {
setLayout(new FlowLayout( ));
p2request = new JLabel( p2 + " choose your character [click on picture]", JLabel.CENTER);
this.add(p2request);
addMouseListener(this);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(zeldmainpc,163,110, this);
g.drawImage(linkmainpc,602,110, this);
g.drawImage(pokemainpc,163,385, this);
g.drawImage(pikamainpc,602,385, this);
}
public void mousePressed(MouseEvent evt) { }
public void mouseEntered(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
public void mouseReleased(MouseEvent evt) { }
public void mouseClicked(MouseEvent evt) {
xpos = evt.getX();
ypos = evt.getY();
if (xpos>=163 && xpos<=497) {
if (ypos>=110 && ypos<=275) {
p2char = "zeld";
}
if (ypos>= 285 && ypos<=560) {
p2char ="link";
}
}
if (xpos<=602 && xpos <= 836) {
if (ypos>=110 && ypos<=275) {
p2char = "poke";
}
if (ypos>= 285 && ypos<=560) {
p2char = "pika";
}
}
cards.next(c);
repaint( );
}
}
class BoardGame extends JPanel {
private LeftPanel left;
private RightPanel right;
public BoardGame( ) {
this.setLayout(null);
left = new LeftPanel( );
left.setLocation(0,0);
left.setSize(660,660);
this.add( left );
right = new RightPanel( );
right.setLocation(600,0);
right.setSize(400,660);
this.add(right);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
}
}
class LeftPanel extends JPanel {
public LeftPanel( ) {
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(monopolyboard,0,0, this);
//player 1 - draw character
if (p1char.equals("zelda")) {
g.drawImage(zeldsprite,xpos1,ypos1,this);
}
else if (p1char.equals("link")) {
g.drawImage(linksprite,xpos1,ypos1,this);
}
else if (p1char.equals("poke")) {
g.drawImage(pokesprite,xpos1,ypos1,this);
}
else if (p1char.equals("pika")) {
g.drawImage(pikasprite,xpos1,ypos1,this);
}
repaint( );
//player 2 - draw character
if (p2char.equals("zelda")) {
g.drawImage(zeldsprite,xpos2,ypos2,this);
}
else if (p2char.equals("link")) {
g.drawImage(linksprite,xpos2,ypos2,this);
}
else if (p2char.equals("poke")) {
g.drawImage(pokesprite,xpos2,ypos2,this);
}
else if (p2char.equals("pika")) {
g.drawImage(pikasprite,xpos2,ypos2,this);
}
repaint( );
}
}
class RightPanel extends JPanel implements ActionListener {
private int roll1;
private int roll2;
private boolean turn = true;
private boolean p1win = false;
private boolean p2win = false;
private boolean firstturn = true;
private JButton roll = new JButton("Roll!");
private JButton buy = new JButton("Buy?");
private JButton done = new JButton("Done");
private JButton forfeit = new JButton("Forfeit");
public RightPanel( ) {
roll.addActionListener(this);
buy.addActionListener(this);
done.addActionListener(this);
forfeit.addActionListener(this);
add(roll);
add(buy);
add(done);
setEnabled(false);
add(forfeit);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Font direct = new Font( "Serif", Font.BOLD, 15 );
g.setFont( direct );
if (turn && !rolled) {
g.setColor(Color.black);
g.drawString(p1 + ", your turn.",60,110);
}
else if (turn && rolled) {
g.setColor(Color.blue);
g.drawString("" + p1 + " you rolled a " + roll1 + " and a "+ roll2 + "",60,90);
g.setColor(Color.red);
if (p1posit == 1 && !firstturn) {
g.drawString("You landed on GO, collect $200",60,110);
}
else if (p1posit == 2) {
g.drawString("You landed on Swimming Pool, Cost $60", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $60",60,130);
p1money -= 60;
p2money += 60;
}
}
else if (p1posit == 3) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p1posit == 4) {
g.drawString("You landed on Field House, Cost $60", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $60",60,130);
p1money -= 60;
p2money += 60;
}
}
else if (p1posit == 5) {
g.drawString("You went to 7-11 for lunch!, Pay $200", 60,110);
p1money -= 200;
}
else if (p1posit == 6) {
g.drawString("You landed on Reading Roadway, Cost $200", 110,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $200",60,130);
p1money -= 200;
p2money += 200;
}
}
else if (p1posit == 7) {
g.drawString("You landed on Orchestra, Cost $110", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $110",60,130);
p1money -= 110;
p2money += 110;
}
}
else if (p1posit == 8) {
g.drawString("You landed on Chance, Take a card!", 600,110);
}
else if (p1posit == 9) {
g.drawString("You landed on Art, Cost $110", 600,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $110",60,130);
p1money -= 110;
p2money += 110;
}
}
else if (p1posit == 10) {
g.drawString("You landed on ROP engineering, Cost $120", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $120",60,130);
p1money -= 120;
p2money += 120;
}
}
else if (p1posit == 11) {
g.drawString("You landed on Jail, but you're just visiting!", 60,110);
}
else if (p1posit == 12) {
g.drawString("You landed on Literature and Writing, Cost $140", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $140",60,130);
p1money -= 140;
p2money += 140;
}
}
else if (p1posit == 13) {
g.drawString("You landed on Electric Company, Cost $140", 60,110);
if (property2[p1posit] == true) {
g.drawString(p2 + " currently owns this! Pay him four times amount shown on dice",60,130);
p1money -= 4*(roll1 + roll2);
p2money += 4*(roll1 + roll2);
}
}
else if (p1posit == 14) {
g.drawString("You landed on Book Analysis, Cost $140", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $410",60,130);
p1money -= 140;
p2money += 140;
}
}
else if (p1posit == 15) {
g.drawString("You landed on Mythology, Cost $160", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $160",60,130);
p1money -= 160;
p2money += 160;
}
}
else if (p1posit == 16) {
g.drawString("You landed on Stevens Creek Roadway, Cost $200", 60,110);
if (property2[p1posit] == true) {
g.drawString(p2 + " currently owns this! Pay him $200",60,130);
p1money -= 200;
p2money += 200;
}
}
else if (p1posit == 17) {
g.drawString("You landed on World History, Cost $160", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $160",60,130);
p1money -= 160;
p2money += 160;
}
}
else if (p1posit == 18) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p1posit == 19) {
g.drawString("You landed on US History, Cost $160", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $160",60,130);
p1money -= 160;
p2money += 160;
}
}
else if (p1posit == 20) {
g.drawString("You landed on Mixed History, Cost $160", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $160",60,130);
p1money -= 160;
p2money += 160;
}
}
else if (p1posit == 21) {
g.drawString("You landed on Lunch Time!", 60,110);
}
else if (p1posit == 22) {
g.drawString("You landed on French, Cost $220", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $220",60,130);
p1money -= 220;
p2money += 220;
}
}
else if (p1posit == 23) {
g.drawString("You landed on Chance!, Take a card!", 60,110);
}
else if (p1posit == 24) {
g.drawString("You landed on Spanish, Cost $220", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $220",60,130);
p1money -= 220;
p2money += 220;
}
}
else if (p1posit == 25) {
g.drawString("You landed on Japanese, Cost $220", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $220",60,130);
p1money -= 220;
p2money += 220;
}
}
else if (p1posit == 26) {
g.drawString("You landed on Stelling Roadway, Cost $200", 60,110);
if (property2[p1posit] == true) {
g.drawString(p2 + " currently owns this! Pay him $200",60,130);
p1money -= 200;
p2money += 200;
}
}
else if (p1posit == 27) {
g.drawString("You landed on Algebra, Cost $260", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $260",60,130);
p1money -= 260;
p2money += 260;
}
}
else if (p1posit == 28) {
g.drawString("You landed on Geometry, Cost $260", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $260",60,130);
p1money -= 260;
p2money += 260;
}
}
else if (p1posit == 29) {
g.drawString("You landed on Water Works, Cost $140", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him four times amount shown on dice",60,130);
p1money -= 4*(roll1 + roll2);
p2money += 4*(roll1 + roll2);
}
}
else if (p1posit == 30) {
g.drawString("You landed on Problem Solving, Cost $260", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $260",60,130);
p1money -= 260;
p2money += 260;
}
}
else if (p1posit == 31) {
g.drawString("You landed on GO TO JAIL, Do not collect $200!", 60,110);
}
else if (p1posit == 32) {
g.drawString("You landed on Biology, Cost $300", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $300",60,130);
p1money -= 300;
p2money += 300;
}
}
else if (p1posit == 33) {
g.drawString("You landed on Chemistry, Cost $300", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $300",60,130);
p1money -= 300;
p2money += 300;
}
}
else if (p1posit == 34) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p1posit == 35) {
g.drawString("You landed on Physics, Cost $320", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $320",60,130);
p1money -= 320;
p2money += 320;
}
}
else if (p1posit == 36) {
g.drawString("You landed on Homestead Roadway, Cost $200", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $200",60,130);
p1money -= 200;
p2money += 200;
}
}
else if (p1posit == 37) {
g.drawString("You landed on Chance, Take a card!", 60,110);
}
else if (p1posit == 38) {
g.drawString("You landed on Java Lab, Cost $360", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $360",60,130);
p1money -= 360;
p2money += 360;
}
}
else if (p1posit ==39) {
g.drawString("You landed on TXT MSG BILLS, Pay $75", 60,110);
p1money -= 75;
}
else if (p1posit == 40) {
g.drawString("You landed on Calculus, Cost $400", 60,110);
if (property2[p1posit] == true) {
g.setColor(Color.green);
g.drawString(p2 + " currently owns this! Pay him $400",60,130);
p1money -= 400;
p2money += 400;
}
}
if (p1money != 0 ) {
g.setColor(Color.cyan);
g.drawString(p1 + ", you have " + p1money + " left", 60, 150 );
}
}
if (!turn && !rolled) {
g.setColor(Color.black);
g.drawString(p2 + ", your turn.",60,90);
}
else if (!turn && rolled) {
g.setColor(Color.blue);
g.drawString("" + p2 + " you rolled a " + roll1 + " and a "+ roll2 + "",60,90);
g.setColor(Color.red);
if (p2posit == 1 && !firstturn) {
g.drawString("You landed on GO, collect $200",60,110);
}
else if (p2posit == 2) {
g.drawString("You landed on Swimming Pool, Cost $60", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $60",60,130);
p2money -= 60;
p1money += 60;
}
}
else if (p2posit == 3) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p2posit == 4) {
g.drawString("You landed on Field House, Cost $60", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $60",60,130);
p2money -= 60;
p1money += 60;
}
}
else if (p2posit == 5) {
g.drawString("You went to 7-11 for lunch!, Pay $200", 60,110);
p2money -= 200;
}
else if (p2posit == 6) {
g.drawString("You landed on Reading Roadway, Cost $200", 110,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $200",60,130);
p2money -= 200;
p1money += 200;
}
}
else if (p2posit == 7) {
g.drawString("You landed on Orchestra, Cost $110", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $110",60,130);
p2money -= 110;
p1money += 110;
}
}
else if (p2posit == 8) {
g.drawString("You landed on Chance, Take a card!", 600,110);
}
else if (p2posit == 9) {
g.drawString("You landed on Art, Cost $110", 600,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $110",60,130);
p2money -= 110;
p1money += 110;
}
}
else if (p2posit == 10) {
g.drawString("You landed on ROP engineering, Cost $120", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $120",60,130);
p2money -= 120;
p1money += 120;
}
}
else if (p2posit == 11) {
g.drawString("You landed on Jail, but you're just visiting!", 60,110);
}
else if (p2posit == 12) {
g.drawString("You landed on Literature and Writing, Cost $140", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $140",60,130);
p2money -= 140;
p1money += 140;
}
}
else if (p2posit == 13) {
g.drawString("You landed on Electric Company, Cost $140", 60,110);
if (property1[p2posit] == true) {
g.drawString(p1 + " currently owns this! Pay him four times amount shown on dice",60,130);
p2money -= 4*(roll1 + roll2);
p1money += 4*(roll1 + roll2);
}
}
else if (p2posit == 14) {
g.drawString("You landed on Book Analysis, Cost $140", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $410",60,130);
p2money -= 140;
p1money += 140;
}
}
else if (p2posit == 15) {
g.drawString("You landed on Mythology, Cost $160", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $160",60,130);
p2money -= 160;
p1money += 160;
}
}
else if (p2posit == 16) {
g.drawString("You landed on Stevens Creek Roadway, Cost $200", 60,110);
if (property1[p2posit] == true) {
g.drawString(p1 + " currently owns this! Pay him $200",60,130);
p2money -= 200;
p1money += 200;
}
}
else if (p2posit == 17) {
g.drawString("You landed on World History, Cost $160", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $160",60,130);
p2money -= 160;
p1money += 160;
}
}
else if (p2posit == 18) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p2posit == 19) {
g.drawString("You landed on US History, Cost $160", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $160",60,130);
p2money -= 160;
p1money += 160;
}
}
else if (p2posit == 20) {
g.drawString("You landed on Mixed History, Cost $160", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $160",60,130);
p2money -= 160;
p1money += 160;
}
}
else if (p2posit == 21) {
g.drawString("You landed on Lunch Time!", 60,110);
}
else if (p2posit == 22) {
g.drawString("You landed on French, Cost $220", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $220",60,130);
p2money -= 220;
p1money += 220;
}
}
else if (p2posit == 23) {
g.drawString("You landed on Chance!, Take a card!", 60,110);
}
else if (p2posit == 24) {
g.drawString("You landed on Spanish, Cost $220", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $220",60,130);
p2money -= 220;
p1money += 220;
}
}
else if (p2posit == 25) {
g.drawString("You landed on Japanese, Cost $220", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $220",60,130);
p2money -= 220;
p1money += 220;
}
}
else if (p2posit == 26) {
g.drawString("You landed on Stelling Roadway, Cost $200", 60,110);
if (property1[p2posit] == true) {
g.drawString(p1 + " currently owns this! Pay him $200",60,130);
p2money -= 200;
p1money += 200;
}
}
else if (p2posit == 27) {
g.drawString("You landed on Algebra, Cost $260", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $260",60,130);
p2money -= 260;
p1money += 260;
}
}
else if (p2posit == 28) {
g.drawString("You landed on Geometry, Cost $260", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $260",60,130);
p2money -= 260;
p1money += 260;
}
}
else if (p2posit == 29) {
g.drawString("You landed on Water Works, Cost $140", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him four times amount shown on dice",60,130);
p2money -= 4*(roll1 + roll2);
p1money += 4*(roll1 + roll2);
}
}
else if (p2posit == 30) {
g.drawString("You landed on Problem Solving, Cost $260", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $260",60,130);
p2money -= 260;
p1money += 260;
}
}
else if (p2posit == 31) {
g.drawString("You landed on GO TO JAIL, Do not collect $200!", 60,110);
}
else if (p2posit == 32) {
g.drawString("You landed on Biology, Cost $300", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $300",60,130);
p2money -= 300;
p1money += 300;
}
}
else if (p2posit == 33) {
g.drawString("You landed on Chemistry, Cost $300", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $300",60,130);
p2money -= 300;
p1money += 300;
}
}
else if (p2posit == 34) {
g.drawString("You landed on Community Chest, Take a card!", 60,110);
}
else if (p2posit == 35) {
g.drawString("You landed on Physics, Cost $320", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $320",60,130);
p2money -= 320;
p1money += 320;
}
}
else if (p2posit == 36) {
g.drawString("You landed on Homestead Roadway, Cost $200", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $200",60,130);
p2money -= 200;
p1money += 200;
}
}
else if (p2posit == 37) {
g.drawString("You landed on Chance, Take a card!", 60,110);
}
else if (p2posit == 38) {
g.drawString("You landed on Java Lab, Cost $360", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $360",60,130);
p2money -= 360;
p1money += 360;
}
}
else if (p2posit ==39) {
g.drawString("You landed on TXT MSG BILLS, Pay $75", 60,110);
p2money -= 75;
}
else if (p2posit == 40) {
g.drawString("You landed on Calculus, Cost $400", 60,110);
if (property1[p2posit] == true) {
g.setColor(Color.green);
g.drawString(p1 + " currently owns this! Pay him $400",60,130);
p2money -= 400;
p1money += 400;
}
}
g.setColor(Color.cyan);
g.drawString(p2 + ", you have " + p2money + " left",60,150);
}
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("Roll!")) {
roll1 = (int)(Math.random( )*6+1);
roll2 = (int)(Math.random( )*6+1);
roll.setEnabled(false);
if (turn == true ) {
p1posit += (roll1+roll2);
if (p1posit >= 40)
p1posit -= 40;
if (price[p1posit] == 0 || property2[p1posit] == true || p1money < price[p1posit])
buy.setEnabled(false);
}
else if (turn == false ) {
p2posit += (roll1+roll2);
if (p2posit >= 40)
p2posit -= 40;
if (price[p2posit] == 0 || property1[p2posit] == true || p2money < price[p2posit])
buy.setEnabled(false);
}
switch (p1posit) {
case 1: xpos1 = 585; ypos1 = 585; break;
case 2: xpos1 = 535; ypos1 = 585; break;
case 3: xpos1 = 485; ypos1 = 585; break;
case 4: xpos1 = 435; ypos1 = 585; break;
case 5: xpos1 = 385; ypos1 = 585; break;
case 6: xpos1 = 335; ypos1 = 585; break;
case 7: xpos1 = 285; ypos1 = 585; break;
case 8: xpos1 = 235; ypos1 = 585; break;
case 9: xpos1 = 185; ypos1 = 585; break;
case 10:xpos1 = 135; ypos1 = 585; break;
case 11:xpos1 = 85; ypos1 = 585; break;
case 12:xpos1 = 85; ypos1 = 485; break;
case 13:xpos1 = 85; ypos1 = 435; break;
case 14:xpos1 = 85; ypos1 = 385; break;
case 15:xpos1 = 85; ypos1 = 335; break;
case 16:xpos1 = 85; ypos1 = 285; break;
case 17:xpos1 = 85; ypos1 = 235; break;
case 18:xpos1 = 85; ypos1 = 185; break;
case 19:xpos1 = 85; ypos1 = 135; break;
case 20:xpos1 = 85; ypos1 = 85; break;
case 21:xpos1 = 135; ypos1 = 85; break;
case 22:xpos1 = 185; ypos1 = 85; break;
case 23:xpos1 = 235; ypos1 = 85; break;
case 24:xpos1 = 285; ypos1 = 85; break;
case 25:xpos1 = 335; ypos1 = 85; break;
case 26:xpos1 = 385; ypos1 = 85; break;
case 27:xpos1 = 435; ypos1 = 85; break;
case 28:xpos1 = 485; ypos1 = 85; break;
case 29:xpos1 = 535; ypos1 = 85; break;
case 30:xpos1 = 585; ypos1 = 85; break;
case 31:xpos1 = 585; ypos1 = 135; break;
case 32:xpos1 = 585; ypos1 = 185; break;
case 33:xpos1 = 585; ypos1 = 235; break;
case 34:xpos1 = 585; ypos1 = 285; break;
case 35:xpos1 = 585; ypos1 = 335; break;
case 36:xpos1 = 585; ypos1 = 385; break;
case 37:xpos1 = 585; ypos1 = 435; break;
case 38:xpos1 = 585; ypos1 = 485; break;
case 39:xpos1 = 585; ypos1 = 535; break;
case 40:xpos1 = 585; ypos1 = 585; break;
}
switch (p2posit) {
case 1: xpos1 = 585; ypos1 = 585; break;
case 2: xpos1 = 535; ypos1 = 585; break;
case 3: xpos1 = 485; ypos1 = 585; break;
case 4: xpos1 = 435; ypos1 = 585; break;
case 5: xpos1 = 385; ypos1 = 585; break;
case 6: xpos1 = 335; ypos1 = 585; break;
case 7: xpos1 = 285; ypos1 = 585; break;
case 8: xpos1 = 235; ypos1 = 585; break;
case 9: xpos1 = 185; ypos1 = 585; break;
case 10:xpos1 = 135; ypos1 = 585; break;
case 11:xpos1 = 85; ypos1 = 585; break;
case 12:xpos1 = 85; ypos1 = 485; break;
case 13:xpos1 = 85; ypos1 = 435; break;
case 14:xpos1 = 85; ypos1 = 385; break;
case 15:xpos1 = 85; ypos1 = 335; break;
case 16:xpos1 = 85; ypos1 = 285; break;
case 17:xpos1 = 85; ypos1 = 235; break;
case 18:xpos1 = 85; ypos1 = 185; break;
case 19:xpos1 = 85; ypos1 = 135; break;
case 20:xpos1 = 85; ypos1 = 85; break;
case 21:xpos1 = 135; ypos1 = 85; break;
case 22:xpos1 = 185; ypos1 = 85; break;
case 23:xpos1 = 235; ypos1 = 85; break;
case 24:xpos1 = 285; ypos1 = 85; break;
case 25:xpos1 = 335; ypos1 = 85; break;
case 26:xpos1 = 385; ypos1 = 85; break;
case 27:xpos1 = 435; ypos1 = 85; break;
case 28:xpos1 = 485; ypos1 = 85; break;
case 29:xpos1 = 535; ypos1 = 85; break;
case 30:xpos1 = 585; ypos1 = 85; break;
case 31:xpos1 = 585; ypos1 = 135; break;
case 32:xpos1 = 585; ypos1 = 185; break;
case 33:xpos1 = 585; ypos1 = 235; break;
case 34:xpos1 = 585; ypos1 = 285; break;
case 35:xpos1 = 585; ypos1 = 335; break;
case 36:xpos1 = 585; ypos1 = 385; break;
case 37:xpos1 = 585; ypos1 = 435; break;
case 38:xpos1 = 585; ypos1 = 485; break;
case 39:xpos1 = 585; ypos1 = 535; break;
case 40:xpos1 = 585; ypos1 = 585; break;
}
rolled = true;
done.setEnabled(true);
}
if (command.equals("Buy?")) {
if (turn == true ) {
property1[p1posit] = true;
p1money -= price[p1posit];
}
else {
property2[p2posit] = true;
p2money -= price[p2posit];
}
buy.setEnabled(false);
}
if (command.equals("Done")) {
if (turn == true ) {
turn = false;
}
else {
turn = true;
firstturn = false;
}
rolled = false;
roll.setEnabled(true);
done.setEnabled(false);
}
if (command.equals("Forfeit")) {
if (turn == true ) {
p2win = true;
cards.next(c);
}
else {
p1win = true;
cards.next(c);
}
}
repaint( );
}
public void CommunityChest( ) {
Scanner community = new Scanner(new File("CommunityChest.txt"));
}
}
class WinnPanel extends JPanel {
public WinnPanel( ) {
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(endedtopsc,0,0,this);
}
}
}