Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package PowerSchool;
- import java.util.ArrayList;
- import TurtleGraphics.KeyboardReader;
- public class PowerSchoolMain {
- public static void main(String[] args) {
- KeyboardReader reader=new KeyboardReader();
- ArrayList <Students> student=new ArrayList <Students>();
- int choice=-1, current=0;
- while(choice!=0) {
- Students thingy=new Students(null, null);
- choice=-1;
- choice=reader.readInt("Which operation\n"
- +"1. Add, Delete, Modify Grades\n"
- + "2. Add, Delete, Modify Students\n"
- + "3. Add Student object to a specific class\n"
- + "4. List all Student objects in a specific class\n"
- + "5. Search for a person given the last name\n"
- + "6. Print out a student's schedule\n"
- + "7. Print out all students\n"
- + "8. Add Progress Report comments to a person object\n"
- + "0: Break\n");
- switch(choice) {
- case 1:
- System.out.println("Which student would you like to change grades for?\n");
- for(int x=0; x<student.size(); x++) {
- System.out.println(x+": "+student.get(x).getName());
- }
- choice=reader.readInt();
- if((student.size()==1)&&((choice<0)||(choice>=student.size()))) {
- choice=reader.readInt("Index must be 0:\n");
- }
- if((choice<0)||(choice>=student.size())) {
- choice=reader.readInt("Index must be between 0 and "+(student.size()-1)+":\n");
- }
- break;
- case 2:
- choice=reader.readInt("Which operation for Students?\n"
- + "1: Add\n"
- + "2: Delete\n"
- + "3: Modify\n"
- + "0: Return to Main Menu\n");
- switch(choice) {
- case 1:
- student.add(thingy);
- String first=reader.readLine("Enter first name: "), last=reader.readLine("Enter last name: ");
- student.get(current).setName(first, last);
- current++;
- break;
- case 2:
- student.remove(thingy);
- break;
- case 3:
- System.out.println("Enter the index to change\n");
- for(int x=0; x<student.size(); x++) {
- System.out.println(x+": "+student.get(x).getName());
- }
- int index=reader.readInt();
- if((student.size()==1)&&((index<0)||(index>=student.size()))) {
- index=reader.readInt("Index must be 0:\n");
- }
- if((index<0)||(index>=student.size())) {
- index=reader.readInt("Index must be between 0 and "+(student.size()-1)+":\n");
- }
- String first1=reader.readLine("Enter first name: "), last1=reader.readLine("Enter last name: ");
- student.get(index).setName(first1, last1);
- }
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- //search for student by name
- boolean doTheDew=false;
- String last=reader.readLine("Enter last name: ");
- for(int x=0; x<student.size(); x++) {
- if(student.get(x).getLast().equalsIgnoreCase(last)){
- System.out.println(student.get(x).getName());
- doTheDew=true;
- }
- }
- if(!doTheDew) {
- System.out.println("No matching students");
- }
- break;
- case 6:
- break;
- case 7:
- for(int x=0; x<student.size(); x++) {
- student.get(x).getName();
- }
- break;
- case 8:
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement