Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP WITH JAVA Objectives: ArrayList File I/O UML diagrams Task: Hogwarts is going digital...and they need your help! The school for witchcraft and wizardry

NEED HELP WITH JAVA

Objectives:

ArrayList

File I/O

UML diagrams

Task: Hogwarts is going digital...and they need your help!

The school for witchcraft and wizardry needs a program to keep track of their enrollment and houses.

If you're unfamiliar with Harry Potter, Hogwarts is the name of a school instructing young wizards and witches. The school has four "houses", and each student enrolled in the school belongs to one. (There's also a bit about sorting, but we'll assume everyone has a house already). Students are additionally identified by what year they are presently in - new students are in their first year, and so on.

Getting Started

Your application will read in data from four text files: year1.txt, year2.txt, year3.txt, and year4.txt. These can be downloaded as a zip file here - unzip it and place the four files in the top of your project in Eclipse.

To get you started, we've provided a test class, Lab2.java. Your final submission must include this class exactly as it appears here. The only permitted modification to this code is to add Javadoc comments as needed. Once your application is completed, running Lab2.java with the given data files will result in the exact output shown below. In addition to this class, you will also create School.java and Student.java. All three of these classes must be in the default package in your project.

Lab2.java

public class Lab2 { public static void main( String[] args ) { School hogwarts = new School("Hogwarts School of Witchcraft & Wizardry"); hogwarts.importStudents("year1.txt"); hogwarts.importStudents("year2.txt"); hogwarts.importStudents("year3.txt"); hogwarts.importStudents("year4.txt"); System.out.println( hogwarts ); } } Output Hogwarts School of Witchcraft & Wizardry Enrollment: 20 Gryffindor: - Colin Creevey (Year:1) - Gryffindor - Ginny Weasley (Year:1) - Gryffindor - Harry Potter (Year:2) - Gryffindor - Hermione Granger (Year:2) - Gryffindor - Ronald Weasley (Year:2) - Gryffindor - Katie Bell (Year:3) - Gryffindor - Lee Jordan (Year:4) - Gryffindor Hufflepuff: - Susan Bones (Year:2) - Hufflepuff - Oliver Rivers (Year:3) - Hufflepuff - Cedric Diggory (Year:4) - Hufflepuff - Zacharias Smith (Year:4) - Hufflepuff Ravenclaw: - Luna Lovegood (Year:1) - Ravenclaw - Stewart Ackerley (Year:1) - Ravenclaw - Cho Chang (Year:3) - Ravenclaw - Felicity Eastchurch (Year:3) - Ravenclaw - Duncan Inglebee (Year:4) - Ravenclaw Slytherin: - Malcolm Baddock (Year:1) - Slytherin - Draco Malfoy (Year:2) - Slytherin - Graham Montague (Year:3) - Slytherin - Terence Higgs (Year:4) - Slytherin

Student.java

The Student class will represent a student at the school, and will therefore be responsible for the student's name, year information, and the name of their house.

Requirements:

Class variables: name of the student, year (numeric value from 1 to 7), name of their house.

Constructor - must take 3 parameters in order: student name, year, and house.

A standard toString method - refer to the sample output for the format.

Getter and setter methods for all class variables.

School.java

The School class will represent an entire school, meaning it will track the total enrollment of the school, all students in attendance, the name of the school, and the names of all houses.

Requirements:

Class variables: name of the school, enrollment (numeric value), an ArrayList of Students, and a String array of house names.

Constructor - must take only 1 parameter, the name of the school

Method importStudents - takes only 1 parameter, the name of the file to be read in. Returns nothing, but populates data within the school.

Method getHouse - takes only 1 parameter, the name of a house, and returns an ArrayList of all students in that house.

A standard toString method - refer to the sample output for the format.

Getter and setter methods for all class variables.

image text in transcribed

Output Hogwarts School of Witchcraft &Wizardry Enrollment: 20 Gryffindor: - Colin Creevey (Year:1) - Gryffindor - Ginny Weasley (Year:1) - Gryffindor - Harry Potter (Year:2) - Gryffindor - Hermione Granger (Year:2) - Gryffindor - Ronald Weasley (Year:2)- Gryffindor - Katie Bell (Year:3) - Gryffindor - Lee Jordan (Year:4)- Gryffindor Hufflepuff: - Susan Bones (Year:2)Hufflepuff - Oliver Rivers (Year:3) -Hufflepuff - Cedric Diggory (Year:4) Hufflepuff - Zacharias Smith (Year:4) - Hufflepuff Ravenclaw: - Luna Lovegood (Year:l) - Ravenclaw - Stewart Ackerley (Year:1) - Ravenclaw - Cho Chang (Year:3) Ravenclaw - Felicity Eastchurch (Year:3) - Ravenclaw Duncan Inglebee (Year:4) - Ravenclaw Slytherin: - Malcolm Baddock (Year:1) - Slytherin - Draco Malfoy (Year:2)- Slytherin - Graham Montague (Year:3)- Slytherin - Terence Higgs (Year:4) - Slytherin

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago