Hi
I only started studying java as a curiousity thing 3 months ago. Naturally i'm intreaged an i'm really enjoying it but the online corse is really vage as to a lot of things. My current assignment is to create a database for a sports team. he says that we have to be able to save and load the information in the program. I should also note the entire thing is in Holts Ready to program. Here is the menu:
for Loading and saving it is telling becasue I use IOException i need to "enclose the subroutine in a try statement that catches the exception or declare that this subroutine throws the excption" nither of witch i understnd below is the two subroutines themselves:int choice; do { c.println("1.Enter player data"); c.println("2.Vew players by last name"); c.println("3.Veiw players by points"); c.println("4.Add another player"); c.println("5.Deleate a player"); c.println("6.Modify a player"); c.println("7.FInd a player by any feild"); c.println("8.Save data"); c.println("9.Load previous data"); c.println("What is it that you would like to do?"); choice=c.readInt(); if (choice==1)EnterData(); if (choice==2)LastName(); if (choice==3)Points(); if (choice==4)AddPlayer(); if (choice==5)Deleate(); if (choice==6)Modify(); if (choice==8)saving(); if (choice==9)Loading(); } while (choice!=10); }
public static void saving() throws IOException { int Y; PrintWriter fileoutput,FileOutput; fileoutput=new PrintWriter(new FileWriter("Playered.txt")); fileoutput.println(Players); for (Y=1;Y<=Players;Y++) { fileoutput.print(Playered[Y][1]); fileoutput.print(Playered[Y][2]); fileoutput.print(Playered[Y][3]); fileoutput.print(Numbers[Y][1]); fileoutput.print(Numbers[Y][2]); } } public static void Loading()throws IOException { String line; int Y,Lines; BufferedReader fileinput; fileinput= new BufferedReader(new FileReader("playered.text")); line=fileinput.readLine(); Players=Integer.valueOf(line).intValue(); c.print(Players); for (Y=1;Y<=Players;Y++) { Playered[Y][1]=fileinput.readLine(); Playered[Y][2]=fileinput.readLine(); Playered[Y][3]=fileinput.readLine(); Numbers[Y][1]=Integer.valueOf(line).intValue(); Numbers[Y][2]=Integer.valueOf(line).intValue(); c.println("reading the record for: "+Playered[Y][1]); c.println("reading the record for: "+Playered[Y][2]); c.println("reading the record for: "+Playered[Y][3]); c.println("reading the record for: "+Numbers[Y][1]); c.println("Reading the record for: "+Numbers[Y][2]); } fileinput.close(); }
As you can see my program uses subroutines that are both strings and Integer nested arrays. I'm not shure if this matters but it beats forgetting something. Thanks
littlemissparadox