Be a Supporter!

How The Heck Do You

  • 433 Views
  • 6 Replies
New Topic Respond to this Topic
Squall-01
Squall-01
  • Member since: Nov. 5, 2003
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
How The Heck Do You 2005-10-11 12:57:27 Reply

Any one know how to make this an applet.

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

/*
// header - edit "Data/yourJavaAppletHeader" to customize
// contents - edit "EventHandlers/Java Applet/onCreate" to customize
*/

public class BowlingApp extends java.applet.Applet
// declare variables
String sgame;
int game1,game2,game3;
int avg;
BufferedReader dataIn =new BufferedReader(new InputStreamReader(System.in));

System.out.print("Please enter the first game's score: ");
sgame = dataIn.readLine();
game1 = Integer.parseInt(sgame);

System.out.print("Please enter the second game's score: ");
sgame = dataIn.readLine();
game2 = Integer.parseInt(sgame);

System.out.print("Please enter the third game's score: ");
sgame = dataIn.readLine();
game3 = Integer.parseInt(sgame);

avg = (game1 + game2 + game3)/3;
System.out.println("Your average score is " + avg);

Image logo; //declares an Image a object
public void init()
{
resize(300,300);
}

public void paint(Graphics g)
{
g.drawString("Hello BowlingApp!", 50, 50);
}
}

Jams44
Jams44
  • Member since: Nov. 8, 2004
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to How The Heck Do You 2005-10-11 15:38:57 Reply

that can't possibly b e all the code?

Ravens-Grin
Ravens-Grin
  • Member since: Jun. 3, 2003
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to How The Heck Do You 2005-10-11 21:39:01 Reply

Is there an option to compile as an applet? There should be.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to How The Heck Do You 2005-10-12 05:02:19 Reply

javac.exe (filename)
and embed the .class file in a website, or use the applet viewer in the java 1.4.2 sdk

there is no difference between two class files in java, an application is "identical" with an applet. The only difference is the defintion of "entry point", an application is being run by an external application (jvm), through a known entry point (public static void main(String args[])) while an applet is initiated throught the abstract function in the Applet class called void init(), and repainted by an abstract function in the same class.


"no sound in ass"

Squall-01
Squall-01
  • Member since: Nov. 5, 2003
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to How The Heck Do You 2005-10-12 13:10:06 Reply

I'm tring to get this dumb ##$# thing as an applet

whatthedeuce
whatthedeuce
  • Member since: Jun. 4, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to How The Heck Do You 2005-10-12 14:25:01 Reply

You need a "{" after the class name (declaration? I don't know what it's called :p).

Squall-01
Squall-01
  • Member since: Nov. 5, 2003
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to How The Heck Do You 2005-10-18 13:48:26 Reply

Never mind I misunderstood the information. I hate java