Question
You are given a person class. You are to write an instructor class derived from the Person class. Each Instructor has a name and an
You are given a person class. You are to write an instructor class derived from the Person class. Each Instructor has a name and an ArrayList of courses s/he teaches. This ArrayList is empty when the instructor is constructed. Create four instructors in main. On each line in your input file there are two strings. The first is the instructors name and the second is a course. As you input this data add the course to the arraylist for that instructor. If the input line is
Henderson CIS101
then add CIS101 to the ArrayList for Henderson
In order to do this you need to add a method called addCourse to the Instructor class. If s is an instructor then s.add"CIS101" adds CIS101 to the arraylist for s1.
You also need a WriteOutput method in instructor. This will write the name then the courses in the ArrayList.
instructors.txt:
Henderson CIS101
James ENG101
Juice SCI201
Henderson CIS102
James PHIL150
Henderson CIS103
Person.java:
public class Person {
protected String name;
public Person() { name = ""; }
public Person(String n) { name = n; }
/** * @return the name */ public String getName() { return name; }
/** * @param name the name to set */ public void setName(String name) { this.name = name; }
public void writeOutput() { System.out.println("Name: "+ name); }
}
Instructor.java:
public class Instructor extends Person { private ArrayList
public Instructor() { super(); } public Instructor(String name,ArrayList
Please help me finish the addCourse method for Instructor.java and the main.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started