Posted: Fri Oct 01, 2004 11:29 am Post subject: New at java need help!!
I'm making a word game based off of DnD, and its not working. What happens is when you pic a race, the stats are supose to pop up, but it doesnt.
Heres my code:
code:
// The "DungeonsAndDragons" class.
import java.awt.*;
import hsa.Console;
public class DungeonsAndDragons
{
static Console c; // The output console
public static void main (String [] args)
{
c = new Console ();
String classes;
String name;
String race;
int str = 10;
int dex = 10;
int Int = 10;
int wis = 10;
int con = 10;
int cha = 10;
c.println ("Whats your name?? <First Name Only>");
name = c.readString ();
c.clear ();
c.println ("What race do you want to be?");
c.println ("human");
// c.println ("dwarf");
//c.println ("elf");
//c.println ("gnome");
//c.println ("half-elf");
//c.println ("half-orc");
//c.println ("halfling");
race = c.readString ();
//c.println ("Your name is, " + name);
//c.println ("Your race is, " + race);
//c.println ("Your class is, " + classes);
// Place your program here. 'c' is the output console
} // main method
} // DungeonsAndDragons class
please help
Sponsor Sponsor
wtd
Posted: Fri Oct 01, 2004 1:11 pm Post subject: (No subject)
I'm not familiar with the proprietary Holt classes, but does the readString method of Console automatically chomp the newline off of input?
That could be the problem. Try testing:
code:
if (race == "human" || race == "human\n")
McKenzie
Posted: Fri Oct 01, 2004 1:45 pm Post subject: (No subject)
2 problems.
1. You can't compare strings like that in Java. try
if (race.equals("human"))
2. Your clear that comes next will clear it before you have a chance to read it
wtd
Posted: Fri Oct 01, 2004 1:54 pm Post subject: (No subject)
McKenzie wrote:
2 problems.
1. You can't compare strings like that in Java. try
if (race.equals("human"))