Answer» Hey, I'm using the book "Beginning Programming with Java for Dummies", and I was attempting to write my own little crappy game with it, I'm shooting for a RPG. And I'm having problems with writing a file a file, and would appreciate any help.
I went through and commented just about everything.
And if you see anything I should change or add or just any tips I'd appreciate it.
Errors: Code: (text) [Select]3 errors found: File: C:\Documents and Settings\<myname>\TextWorld\Main.java [line: 88] Error: C:\Documents and Settings\<myname>\TextWorld\Main.java:88: illegal start of expression File: C:\Documents and Settings\<myname>\TextWorld\Main.java [line: 88] Error: C:\Documents and Settings\<myname>\TextWorld\Main.java:88: not a statement File: C:\Documents and Settings\<myname>\TextWorld\Main.java [line: 88] Error: C:\Documents and Settings\<myname>\TextWorld\Main.java:88: ';' expected
Script: (WARNING: NEW PROGRAMMER'S FIRST SCRIPT) Code: (text) [Select]//Imports Start\\ import java.util.Scanner;//Imports Scanner import java.io.File;//Imports File import java.io.FileNotFoundException;//Imports a suggested thing in case file not found. import java.io.PrintStream;//Imports Printer for files //Imports End\\
//----------\\
//Class Start\\ class TextWorld { //Start of class TextWorld //Main Method Start\\ public static void main(String args[]) { //Start of my main method beginGame(); //Starts the game } //Main Method End\\ //----------\\ //Methods Start\\ //Start Menu Start\\ public static void beginGame(){ //The starting method called by main method Scanner numChecker = new Scanner(System.in); //New scanner called numChecker for checking the number input. int num; //New int for the numChecker to record in. //Some text options. System.out.println("Hello and welcome to TextWorld!"); System.out.println("[Options]"); System.out.println("[1]-Login if your an existing user."); System.out.println("[2]-To create a new account."); System.out.println("[3]-To exit TextWorld."); System.out.println("Note 1: To choose an option type the assinged number to it."); System.out.println("Note 2: Please refrain from typing anything that isn't a number unless told OTHERWISE."); num = numChecker.nextInt(); //Uses the Scanner numChecker to get the next int and put it in variable num. //Checks to see what option they chose if (num == 1) { login(); } if (num == 2) { newUser(); } if (num == 3) { System.out.println("Program stopped."); } if (num < 1 || num > 3) { System.out.println("INVALID Command."); beginGame(); } } //Start Menu End\\ //---------\\ //Character Login Start\\ public static void login() { //Note: I just setup this method before hand so don't worry about this. Scanner nameChecker = new Scanner(System.in); //Scanner to check name String characterName; //variable to STORE the players string and hopefully will soon check and see if it exists. System.out.print("Name:"); //Asks for user's name of character name = nameChecker.nextLine(); //Gets the string they type and puts it in name. System.out.println(name); //Just a check to make sure it's reading it. Will remove later. } //Character Login End\\ //----------\\ //New Character Start\\ public static void newCharacter() { //This is for when they make a new character. It's supposed to record everything to a new file. Scanner nameChecker = new Scanner(System.in); //New scanner that will check and see what name they want. String characterName; //String variable to hold their name and compare it with used names to see if it's available. Don't actually know how to do this yet. int characterClass = 0; //Will set the character class that they choose. I will determine class by numbers. int statStrength = 0; //Number for their strength STAT. int statDefense = 0; //Number for their defense stat. int statVitality = 0; //Number for their vitality stat. int statWisdom = 0; //Number for their wisdon stat. //Will add in a input for their name and the nameCheck as soon as I figure it out. } //New Character End\\ //----------\\ //Character Name In Use Check Start\\ public static void nameCheck() { //Will check and see if a name already exists. throws FileNotFoundException { //Book says your supposed to add this. ALL ERRORS HERE Scanner nameScanner = new Scanner(new File("characters\\name.txt")); //The book says it's supposed to work. System.out.println(diskScanner.fineInLine(".").charAt(0)); //I am STILL trying to figure out how to work this line. } } //Character Name In Use Check End\\ //Methods End\\ } //Class Ends\\Code: [Select]System.out.println(diskScanner.fineInLine(".").charAt(0)); //I am still trying to figure out how to work this line Might just be a typo. I think you want the findInLine method of Scanner, not fineInLine.
|