Complete the following steps to modify some of these classes
Complete the following steps to modify some of these classes so that it will also print out the information on the SI of the class too.
Add SI class that has three instance variables (first name, Last name, Office hours)
Add all the methods required for this class (including toString() method)
Modify the course class toString() method so that it will also print out the information on SI.
Modify the client so that it works with the additional class.
Solution
/**
 * This program demonstrates the Course class.
 */
public class CourseDemo
 {
 public static void main(String[] args)
 {
 // Create an Instructor object.
 Instructor myInstructor =
 new Instructor(\"Kramer\", \"Shawn\", \"RH3010\");
   
 // Create a TextBook object.
 TextBook myTextBook =
 new TextBook(\"Starting Out with Java\",
 \"Gaddis\", \"Addison-Wesley\");
   
 SI newSI = new SI(\"Kramer\", \"Shawn\", \"9AM to 5PM\"); // Added SI instance
 
 // Create a Course object.
 Course myCourse =
 new Course(\"Intro to Java\", myInstructor,
 myTextBook, newSI); //pass SI to the constructor
   
 // Display the course information.
 System.out.println(myCourse);
 }
 }
//---------------------------------------------------------------------------------------
/**
 * This class stores information about a course.
 */
public class Course
 {
 private String courseName; // Name of the course
 private Instructor instructor; // The instructor
 private TextBook textBook;   
 private SI si;
 public Course(String name, Instructor instr,
 TextBook text, SI si)
 {
 // Assign the courseName.
 courseName = name;
   
 // Create a new Instructor object, passing
 // instr as an argument to the copy constructor.
 instructor = instr;
// Create a new TextBook object, passing
 // text as an argument to the copy constructor.
 textBook = text;
   
 this.si = si;
   
 }
/**
 * getName method
 */
 
 public String getName()
 {
 return courseName;
 }
 
 /**
 * getInstructor method
 */
 
 public Instructor getInstructor()
 {
 // Return a copy of the instructor object.
 return instructor;
 }
/**
 * getTextBook method
 */
 
 public TextBook getTextBook()
 {
 // Return a copy of the textBook object.
 return textBook;
 }
 
 
 public SI getSi()
 {
    // Return a copy of the textBook object.
    return si;
 }
/**
 * The toString method returns a string containing
 * the course information.
 */
public String toString()
 {
 // Create a string representing the object.
 String str = \"Course name: \" + courseName
 + \"\ Instructor Information:\ \"
 + instructor
 + \"\ Textbook Information:\ \"
 + textBook
 + \"\ SI Information:\ \"
 + si;
// Return the string.
 return str;
 }
 }
//--------------------------------------------------------------------------------------------------------
/**
 * This class stores information about a SI.
 */
 public class SI {
String firstName, lastName, officeHours;
   public SI(String firstName, String lastName, String officeHours) {
        super();
        this.firstName = firstName;
        this.lastName = lastName;
        this.officeHours = officeHours;
    }
   
    public void set(String lname, String fname,
 String office)
    {
        lastName = lname;
        firstName = fname;
        officeHours = office;
    }
   public String getFirstName() {
        return firstName;
    }
   public String getLastName() {
        return lastName;
    }
   public String getOfficeHours() {
        return officeHours;
    }
   @Override
    public String toString() {
       
        String str = \"Last Name: \" + lastName
 + \"\ First Name: \" + firstName
 + \"\ Office Hours: \" + officeHours;
        return str;
    }
   
   
 }
//---------------------------------------------------------------------------------------------



