Driver

HogwartsAndWizardDriver:

This driver tests all the methods, such as the newly added selection sort method, that are used in each of the classes. It creates new Wizard objects and Hogwarts objects and tests their methods as well as using polymorphism on a School object. For more information about the different methods and objects tested in this class, refer to the comments made in my code as well as in the other classes and interface.

Code

import javax.swing.JOptionPane;//imports JOptionPane

import java.util.*;//imports ArrayList

public class HogwartsAndWizardDriver//this is a driver that you can use to test both classes

{

public static void main(String [] args)

{

Wizard wizard1 = new Wizard();//creates a new Wizard object

System.out.println(wizard1);//prints out the object

System.out.println();//adds a line for organizational purposes

wizard1.selectionSortClasses();//calls the method from the Wizard class to sort the classes of the student with selection sort

System.out.println("If you look above, you can see " +wizard1.getFirstName()+

"\'s classes. Below are their classes after being put through selection sort: \n" + wizard1.getTheClassElements());

//Prints out the classes after using the selection sort method

String wizardFirstName = JOptionPane.showInputDialog(null, "Enter the first name of your wizard.");

//asks the user for the name of their wizard

String wizardLastName = JOptionPane.showInputDialog(null, "Enter the last name of yout wizard.");

//asks the user for the last name of their wizard

String userWand = JOptionPane.showInputDialog(null, "There are three wand types available. Press 1 for a phoenix feather wand. Press 2 for a unicorn hair wand. Press 3 for a dragon heartstring wand.");

//asks the user to enter a number between 1 and 3 to choose their wand

String wizardHouse = JOptionPane.showInputDialog(null, "What house is your wizard in?");//asks the user what hogwarts house their object is in

String wizardAge = JOptionPane.showInputDialog(null,"What is the age of your wizard?");//asks the user for the age of their object

String injury = JOptionPane.showInputDialog(null, "Is your wizard injured? Type in true or false.");//asks the user for the age of their object

String wizardLocation = JOptionPane.showInputDialog(null, "Where is your wizard?");//asks the user for the location of their wizard

int wizardAges = Integer.parseInt(wizardAge);//parses the age of the wizard so that the value is an integer and not a String

Wizard wizard2 = new Wizard();//creates a new object

wizard2.setFirstName(wizardFirstName);//calls the setter method for the first name of the ojbect and sets the parameters

wizard2.setLastName(wizardLastName);//calls the setter method for the last name of the ojbect and sets the parameters

wizard2.setWandType(userWand);//calls the setter method for the wand type of the ojbect and sets the parameters

wizard2.setHouse(wizardHouse);//calls the setter method for the hogwarts house of the ojbect and sets the parameters

wizard2.setAge(wizardAges);//calls the setter method for the age of the ojbect and sets the parameters

wizard2.setInjured(injury);//calls the setter method for the injury status of the ojbect and sets the parameters

wizard2.setLocation(wizardLocation);//calls the setter method for the location of the ojbect and sets the parameters

System.out.println(wizard2);//prints out the object

System.out.println();//adds a line for organizational purposes

Hogwarts hogwarts1 = new Hogwarts ();//creates a new object

System.out.println(hogwarts1);//prints out the new object using its zero argument contstructor

System.out.println();//adds a line for organizational purposes

System.out.println("Wisest wizard: \n" + hogwarts1.wisestWizard());//calls the method wisestWizard and prints the value

System.out.println();//adds a line for organizational purposes

System.out.println("Battle 1 Results: \n" +hogwarts1.Battle(new Wizard("Fred", "Weasley", 17, "Unicorn hair", "Gryffindor", false, false, "Gryffindor common room", new String [] {"Transfiguration, ", " Potions, ", "Defense Against the Dark Arts."}),

new Wizard("George", "Weasley", 17, "Dragon heartstring", "Gryffindor", false, false, "Secret location", new String [] {"Transfiguration, ", " Potions, ", "Defense Against the Dark Arts."} )));

//prints out the results of one battle after calling the method Battle()

System.out.println();//adds a line for organizational purposes

System.out.println("Battle 2 Results: \n" + hogwarts1.Battle(new Wizard ("Cho", "Chang", 16, "Unicorn hair", "Ravenclaw", false, false, "Ravenclaw common room", new String [] {"Transfiguration, ", " Potions, ", "Defense Against the Dark Arts."}),

new Wizard ("Seamus", "Finnigan", 16, "Dragon heartstring", "Gryffindor", false, false, "Gryffindor common room", new String [] {"Transfiguration, ", " Potions, ", "Defense Against the Dark Arts."} )));

//prints out the results of one battle after calling the method Battle()

System.out.println();//adds a line for organizational purposes

System.out.println(hogwarts1.takingOWLExams());//calls the method takingOWLExams and returns the results by printing them

System.out.println();//adds a line for organizational purposes

System.out.println("Classes of each student: \n"+hogwarts1.wizardStudentClasses());//calls the method wizardStudentClasses and prints out the classes each student has

System.out.println("Did Dumbledore's Army defeat the Death Eaters?: \n" +hogwarts1.defeatTheDeathEaters());//calls the method defeatTheDeathEaters and prints out the results

System.out.println();//adds a line for organizational purposes

hogwarts1.apparationForHarry();//calls the method apparationForHarry (this is one part of the pair of the overloaded method)

System.out.println("Harry's new location: " + hogwarts1.getHarrysLocation());//calls the method getHarrysLocation and returns the results

hogwarts1.apparationForHarry("Forbiden forest");//sets the method apparationForHarry to the forbiden forest (This is one part of the pair of the overloaded method)

System.out.println("Harry's newest location: " +hogwarts1.getHarrysLocation());//calls the method getHarrysLocation and returns the results

System.out.println();//adds a line for organizational purposes

System.out.println("Ron and Hermione's couple name: "+hogwarts1.ronAndHermioneLove());//calls the method ronAndHermioneLove and returns the results

System.out.println();//adds a line for organizational purposes

School hogwarts2 = new Hogwarts();//I am using polymorphism and creating a school object with hogwarts methods.

String schoolStart = JOptionPane.showInputDialog(null,"Enter the start of the school day. Please enter a number between 1 and 24, like in a 24 hour clock.");

//asks the user to enter the start of the school day

int start = Integer.parseInt(schoolStart);

//parses the user input because it was a String

String schoolEnd = JOptionPane.showInputDialog(null, "Enter the end of the school day. Please enter a number between 1 and 24, like in a 24 hour clock. You must enter a number after the time you listed for the start.");

//asks the suer to enter the end of the school day

int end = Integer.parseInt(schoolEnd);

//parses the user input because it was a String

System.out.println("School hours: " + hogwarts2.schoolHours(start, end));

//calls the method from the School class to print out the hours in one school day

System.out.println();//adds a line for organizational purposes

String schoolSize = JOptionPane.showInputDialog(null, "Enter the amount of students at this school.");

int size = Integer.parseInt(schoolSize);//parses the user data into an integer so that

System.out.println("School size info: "+ hogwarts2.fullSchool(size));

//this calss the method from the School class and returns the school size status.

}

}

Code Snapshots