...

View Full Version : Help with java!!



bina24
01-21-2009, 09:37 AM
how dio I fix a HTML file to my java game, that I've made?

I need more javadoc documentation in my code. Need help with that too.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
public class Spelautomat extends Applet implements MouseListener { // Klassen Spelautomat

int x;
int y;
int z;
public void init()
{
addMouseListener(this);

// Sätter in Z här i init event, det här är pengarna som man får början med.
z = 100;
}

public void paint(Graphics g)
{
g.drawString("column is " + x +" row is " + y,x,y); // Lägger upp värden på kolumnerna.
g.drawString("Name : Sabina Ghidey",20,20); // Namn på spelare.
g.drawString("Project : Spel Automat",20,35);
g.drawString("Spel Automat",285,95);
g.drawString("Vad One",200,345);
g.drawString("Vad Max",300,345);
g.drawString("Snurra",410,345);
Random a = new Random();
//Random b = new Random();
//Random c = new Random();

int answer1 = a.nextInt(9);
int answer2 = a.nextInt(9);
int answer3 = a.nextInt(9);
g.drawString(" "+answer1,175,200);
g.drawString(" "+answer2,325,200);
g.drawString(" "+answer3,475,200);

g.drawRect(100,100,150,200);
g.drawRect(250,100,150,200);
g.drawRect(400,100,150,200);
g.drawRect(185,325,75,30);
g.drawRect(285,325,75,30);
g.drawRect(385,325,75,30);
if(x >= 185 && x<= 260 && y>= 325 && y<= 355)
g.drawString("Box 0",20,50);
else
if(x >= 285 && x<= 360 && y>= 325 && y<= 355)
g.drawString("Box 1",20,50);
else
if(x >= 385 && x<= 460 && y>= 325 && y<= 355)
g.drawString("Box 2",20,50);


if ((answer1 == answer2) && (answer2 == answer3)) {
g.drawString("DU VANN!!",300,600);
// Om personen vinner igen, läggs det till 100 poäng.
z += 100;
}
else {
// Annars minskas vadet.
z -= 3;
}

// Addera det totala mynt värdet.
g.drawString("Mynt "+ z,375,95);

}


public void mouseClicked(MouseEvent e)
{
x = e.getX();
y = e.getY();

abduraooft
01-21-2009, 09:40 AM
Java and javascript are not the same, request a moderator to move your thread to the right sub forum.

Philip M
01-21-2009, 09:59 AM
And please read the posting guidelines about silly thread titles and the use of <code> tags.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum