Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help with java!!

    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();

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Java and javascript are not the same, request a moderator to move your thread to the right sub forum.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,982
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    And please read the posting guidelines about silly thread titles and the use of <code> tags.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •