/** * @(#)markmanager.java * * * @author mike C * @version 1.00 2007/2/26 */ import java.io.*; import java.util.Arrays; import java.util.ArrayList; public class marksManager { static int selectedMode=0; static ArrayList studentTracker = new ArrayList(); /* selectedMode Mode Reference- 0.On Main Menu 1.Create New Student 2.Edit Student information 3.Overview 4.Exit Program :( */ private static void mainMenu () { System.out.println("\n Manage Marks and Stuff- \n 1.New Student \n 2.Edit Student \n 3.Overview \n 4.Exit Program"); } public static void alphaSort(){ char[] name1, name2; String nam1,nam2; student placeHolder; student[] tempArray = new student[studentTracker.size()]; for(int i=0;i= 0){// Check For the same last name, if true compares first names. //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" has the same last name as "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); nam1= tempArray[i].showFirstName().toLowerCase(); nam2= tempArray[i+1].showFirstName().toLowerCase(); name1 = nam1.toCharArray(); name2 = nam2.toCharArray(); } for (int j=0;j <= name1.length;j++){ if (name1[j] > name2[j]){ //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" goes behind "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); placeHolder=tempArray[i]; tempArray[i]=tempArray[i+1]; tempArray[i+1]=placeHolder; break; } else { if (name1[j] < name2[j]){ //System.out.println(tempArray[i].showLastName()+", "+tempArray[i].showFirstName()+" is in proper position between "+tempArray[i+1].showLastName()+", "+tempArray[i+1].showFirstName() ); break; } } } } } /*for (int k=0;k=0 || temp2.indexOf("Y")>=0){ // If satisfied with input create a new student (create a temp array, then make the main equal to the temp) satisfaction = true; studentTracker.add(studentTracker.size(),new student(nameLast,nameFirst,numberStudent)); break; } } } System.out.println("Back to Main Menu."); } public static void editStudent () throws IOException { // 1. Change Student Information, 2. Add Marks, 3. Edit Marks // Show class then take either a name or a student number System.out.println("\n Manage Student Information- \n 1.Change Student Information \n 2.Add Marks \n 3.Edit Marks "); selectedMode=choice(selectedMode,3); switch(selectedMode){ case(1): System.out.println("CHANGE STUDENT INFO"); break; case(2): System.out.println("ADD MARKS"); break; case(3): System.out.println("EDIT MARKS"); break; default: System.out.println("Back to main menu."); } } public static void overView () throws IOException { // Show Individual Marks, or Show Class Marks System.out.println("There are currently "+studentTracker.size()+" students being accounted for."); for (int i=0; studentTracker.size() >i ; i++){ studentTracker.get(i).displayInfo(); } } public static void deleteStudent () throws IOException { } public static int choice (int currentSel, int upperBounds) throws IOException { BufferedReader getIN = new BufferedReader (new InputStreamReader (System.in)); for (int inf=0;;inf++){ for (int inf2=0;;inf2++){ String temp = getIN.readLine(); int i = Integer.parseInt(temp); if (i <= upperBounds & i >= 1){ System.out.println("Acceptable"); return i; }else{ System.out.println("Sorry, that's not a valid option."); break; } } } } public static void main(String[] args) throws IOException { boolean letMeOut = false; while (letMeOut == false){ mainMenu(); selectedMode=choice(selectedMode, 4); switch(selectedMode){ case(1): newStudent (); break; case(2): System.out.println("There are "+studentTracker.size()+" unique students, being tracked."); editStudent(); break; case(3): overView(); break; case(4): letMeOut=true; default: //mainMenu(); System.out.println("Thanks for using this useless program, all your hard work in data input is now being deleted. \n Have a nice day. :)"); } } } }