Advertisement
Guest User

main

a guest
Feb 11th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.16 KB | None | 0 0
  1. package PowerSchool;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import TurtleGraphics.KeyboardReader;
  6.  
  7. public class PowerSchoolMain {
  8.  
  9.     public static void main(String[] args) {
  10.         KeyboardReader reader=new KeyboardReader();
  11.         ArrayList <Students> student=new ArrayList <Students>();
  12.         int choice=-1, current=0;
  13.         while(choice!=0) {
  14.             Students thingy=new Students(null, null);
  15.             choice=-1;
  16.             choice=reader.readInt("Which operation\n"
  17.                     +"1. Add, Delete, Modify Grades\n"
  18.                     + "2. Add, Delete, Modify Students\n"
  19.                     + "3. Add Student object to a specific class\n"
  20.                     + "4. List all Student objects in a specific class\n"
  21.                     + "5. Search for a person given the last name\n"
  22.                     + "6. Print out a student's schedule\n"
  23.                     + "7. Print out all students\n"
  24.                     + "8. Add Progress Report comments to a person object\n"
  25.                     + "0: Break\n");
  26.             switch(choice) {
  27.                 case 1:
  28.                     System.out.println("Which student would you like to change grades for?\n");
  29.                     for(int x=0; x<student.size(); x++) {
  30.                         System.out.println(x+": "+student.get(x).getName());
  31.                     }
  32.                     choice=reader.readInt();
  33.                     if((student.size()==1)&&((choice<0)||(choice>=student.size()))) {
  34.                         choice=reader.readInt("Index must be 0:\n");
  35.                     }
  36.                     if((choice<0)||(choice>=student.size())) {
  37.                         choice=reader.readInt("Index must be between 0 and "+(student.size()-1)+":\n");
  38.                     }      
  39.                     break;
  40.                 case 2:
  41.                     choice=reader.readInt("Which operation for Students?\n"
  42.                             + "1: Add\n"
  43.                             + "2: Delete\n"
  44.                             + "3: Modify\n"
  45.                             + "0: Return to Main Menu\n");
  46.                     switch(choice) {
  47.                     case 1:
  48.                         student.add(thingy);
  49.                         String first=reader.readLine("Enter first name: "), last=reader.readLine("Enter last name: ");
  50.                         student.get(current).setName(first, last);
  51.                         current++;
  52.                         break;
  53.                     case 2:
  54.                         student.remove(thingy);
  55.                         break;
  56.                     case 3:
  57.                         System.out.println("Enter the index to change\n");
  58.                         for(int x=0; x<student.size(); x++) {
  59.                             System.out.println(x+": "+student.get(x).getName());
  60.                         }
  61.                         int index=reader.readInt();
  62.                         if((student.size()==1)&&((index<0)||(index>=student.size()))) {
  63.                             index=reader.readInt("Index must be 0:\n");
  64.                         }
  65.                         if((index<0)||(index>=student.size())) {
  66.                             index=reader.readInt("Index must be between 0 and "+(student.size()-1)+":\n");
  67.                         }
  68.                         String first1=reader.readLine("Enter first name: "), last1=reader.readLine("Enter last name: ");
  69.                         student.get(index).setName(first1, last1);
  70.                     }
  71.                     break;
  72.                 case 3:
  73.                     break;
  74.                 case 4:
  75.                     break;
  76.                 case 5:
  77.                     //search for student by name
  78.                     boolean doTheDew=false;
  79.                     String last=reader.readLine("Enter last name: ");
  80.                     for(int x=0; x<student.size(); x++) {
  81.                         if(student.get(x).getLast().equalsIgnoreCase(last)){
  82.                             System.out.println(student.get(x).getName());
  83.                             doTheDew=true;
  84.                         }
  85.                     }
  86.                     if(!doTheDew) {
  87.                         System.out.println("No matching students");
  88.                     }
  89.                     break;
  90.                 case 6:
  91.                     break;
  92.                 case 7:
  93.                     for(int x=0; x<student.size(); x++) {
  94.                         student.get(x).getName();
  95.                     }
  96.                     break;
  97.                 case 8:
  98.                     break;
  99.             }
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement