Solved

Can Some Compile Something For Me...?

Posted on 1998-05-07
12
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java: The Public Class Main 4 65
how to debug htl and js pages 8 78
java example issue 5 65
How to configure empty element in XML Document parser? 15 58
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

734 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