Solved

Can Some Compile Something For Me...?

Posted on 1998-05-07
12
155 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Expert Comment

by:java_kevin
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 4

Expert Comment

by:evijay
Comment Utility
No.

0
 

Expert Comment

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

Author Comment

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

Expert Comment

by:java_kevin
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count7 challenge 12 66
nestparen challenge 4 55
groovy example issue 10 64
micro services spring boot application error 3 13
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now