Question: NEED HELP WITH JAVA provided with text files to check the output Objectives: ArrayList File I/O Getting Started Your application will read in data from

NEED HELP WITH JAVA

provided with text files to check the output

Objectives:

ArrayList

File I/O

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 ); } }

TEXT FILES

year1.txt

Colin Creevey,Gryffindor Luna Lovegood,Ravenclaw Ginny Weasley,Gryffindor Stewart Ackerley,Ravenclaw Malcolm Baddock,Slytherin

year2.txt

Harry Potter,Gryffindor Susan Bones,Hufflepuff Draco Malfoy,Slytherin Hermione Granger,Gryffindor Ronald Weasley,Gryffindor

year3.txt

Cho Chang,Ravenclaw Katie Bell,Gryffindor Felicity Eastchurch,Ravenclaw Oliver Rivers,Hufflepuff Graham Montague,Slytherin

year4.txt

Cedric Diggory,Hufflepuff Lee Jordan,Gryffindor Terence Higgs,Slytherin Duncan Inglebee,Ravenclaw Zacharias Smith,Hufflepuff

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.

NEED HELP WITH JAVA provided with text files to check the output

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!