Solved

Can Some Compile Something For Me...?

Posted on 1998-05-07
12
157 Views
Last Modified: 2013-11-23
I need someone to compile something for me as my sysadmin still has not installed the JDK on the UNIX machine.  Anyone who has the JDK either email me here:

aslan@yeat.ml.org

Or leave you answer as an answer on here.  Also can someone improve on this game I have, the one that needs to be compiled?  Like make it keep score, choose which di you want to keep and roll the other one; also turn it into Java 1.1?  Here is the code below:

import java.awt.*;
import java.awt.event.*;

/*
 *
 * This script was coded by Michael Lauzon, (C) 1998.
 * And not to be used without the express written
 * consent of its author: ce940@freenet.toronto.on.ca
 *
 */

public class Craps extends java.applet.Applet implements ActionListener {
  Die die1 = new Die();
  Die die2 = new Die();
  int wins = 0;
  int losses = 0;
  int point = 0;
  final String WINNER = "Winner!";
  final String LOSER = "Craps!";
  String resultText = "";
  Button rollButton = new Button("Roll Dice");

  public void init() {
    setBackground(Color.green);
    rollButton.addActionListener(this);
    add(rollButton);
  }

  public void paint(Graphics screen) {
    die1.drawDie(screen, 5, 50);
    die2.drawDie(screen, 175, 50);
    screen.setColor(Color.black);
    Font f = new Font("Times New Roman", Font.BOLD, 15);
    screen.setFont(f);
    if (point != 0) {
      screen.drawString(point + " wins and 7 craps out.", 5, 200);
    } else {
      screen.drawString("7 or 11 win; 2, 3, or 12 crap out.", 5, 200);
    }
    screen.drawString("Number of wins: " + wins, 5, 220);
    screen.drawString("Number of losses: " + losses, 5, 240);
    if (resultText != "") {
      f = new Font("Times New Roman", Font.BOLD, 30);
      screen.setFont(f);
      screen.drawString(resultText, 85, 110);
      resultText = "";
    }
  }

  public void actionPerformed(ActionEvent event) {
    die1.rollValue(6);
    die2.rollValue(6);
    checkResult(die1, die2);
    repaint();
  }

  public void checkResult(Die d1, Die d2) {
    if (point == 0) {
      point = d1.value + d2.value;
      if ( (point == 7) | (point == 11) ) {
        resultText = WINNER;
      }
      if ( (point < 4) | (point == 12) ) {
        resultText = LOSER;
      } else {
        if (d1.value + d2.value == point) {
          resultText = WINNER;
        }
        if (d1.value + d2.value == 7) {
          resultText = LOSER;
        }
      }
      if (resultText == WINNER) {
        wins++;
        point = 0;
      }
      if (resultText == LOSER) {
        losses++;
        point = 0;
      }
    }
  }
}


Thanks for any help you can give me.
0
Comment
Question by:CyberMage
12 Comments
 

Expert Comment

by:java_kevin
ID: 1220750
I think yours is similar or same as
http://homer.pacific.net.sg/~thheugene/craps.html

maybe u can just obtain the class form here?
0
 

Expert Comment

by:java_kevin
ID: 1220751
I think yours is similar or same as
http://homer.pacific.net.sg/~thheugene/craps.html

maybe u can just obtain the class form here?

Otherwise, u need to include the source for Die class too. Else, we have to make those lines into comments
0
 

Author Comment

by:CyberMage
ID: 1220752
Well, if it is the same...God only knows why; is there anyway you  can make it keep score and stuff (make it more flavourable)?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Expert Comment

by:java_kevin
ID: 1220753
Maybe someone infringed the copyright laws... hehe

I can make it keep scores. They will be kept according to your requirements. And the results can be shown in some special/nice way. Bars, graph...etc

But to compile them properly, I need the Die class too. Else there'll be compile errors. Mind sending them to determined@mariah-carey.com ? The .java

Pls send them ASAP to compile. If after compilation, u have any problems, free to ask mi.

Although I started applet only this yr, I'll try to help.

Anyway, if u want, u can down JDK from www.javasoft.com and kawa (IDE for java) www.tek-tools.com . Pay attention to kawa's compatibility for jdk's version.
0
 

Expert Comment

by:java_kevin
ID: 1220754
I noticed that you didn't import java.applet.Applet.

i use jdk 1.1.5

You need to send me the .java of Die class ASAP to get everything right. I noticed that you have some syntax errors.
How long have u been doing java?
0
 

Author Comment

by:CyberMage
ID: 1220755
I haven't been doing Java long, and I can't use the JDK...as the sysadmin has yet to install it; once he figures out how.  I'll send you the Craps.java as soon as I can.
0
 
LVL 4

Expert Comment

by:evijay
ID: 1220756
No.

0
 

Expert Comment

by:java_kevin
ID: 1220757
How? Found the craps and die.java?
Been a long time already...
0
 

Author Comment

by:CyberMage
ID: 1220758
Craps.java is the whole Java program, there is nothing else to
it...WYSIWYG.
0
 

Expert Comment

by:java_kevin
ID: 1220759
Sorry, I actually mean the die.java...
I didn't receive the die.java yet...

If no die.java, errors will be many...maybe i try to do a basic die.java to compile and see any errors. try to send die.java ASAP. thanks.

Any errors, i solve then after get .class, will make those additional lines into comments so u can see.
0
 
LVL 1

Expert Comment

by:vijayakumar
ID: 1220760
Can you attach Die.java for me so that i can compile for you
0
 
LVL 5

Accepted Solution

by:
fontaine earned 100 total points
ID: 1220761
No need to wait for your sysadmin waking up ;-).
Go here, this is an on-line compiling service:

http://www.innovation.ch/java/java_compile.html
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 45
diffSum example 4 50
throw exception 21 58
Need Help! Getting a syntax error and don't understand why 3 31
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question