Use Java. Given main(), define a Course base class with methods to set and get the courseNumber and courseTitle. Also define a derived class OfferedCourse with methods to set and get instructorName, term, and classTime. Ex. If the input is: ECE287 Digital Systems Design ECE387 Embedded Systems Design Mark Patterson Fall 2018 WF: 2-3:30 pm the output is: Course Information: Course Number: ECE287 Course Title: Digital Systems Design Course Information: Course Number: ECE387 Course Title: Embedded Systems Design Instructor Name: Mark Patterson Term: Fall 2018 Class Time: WF: 2-3:30 pm import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, term, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); term = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle); myCourse.printInfo(); myOfferedCourse.setCourseNumber(oCourseNumber); myOfferedCourse.setCourseTitle(oCourseTitle); myOfferedCourse.setInstructorName(instructorName); myOfferedCourse.setTerm(term); myOfferedCourse.setClassTime(classTime); myOfferedCourse.printInfo(); System.out.println(" Instructor Name: " + myOfferedCourse.getInstructorName()); System.out.println(" Term: " + myOfferedCourse.getTerm()); System.out.println(" Class Time: " + myOfferedCourse.getClassTime()); } } public class Course{ // TODO: Declare private fields - courseNumber, courseTitle /*answer/* // TODO: Define mutator methods - // setCourseNumber(), setCourseTitle() /*answer/* // TODO: Define accessor methods - // getCourseNumber(), getCourseTitle() /*answer/* // TODO: Define printInfo() /*answer/* } public class OfferedCourse extends Course { // TODO: Declare private fields - instructorName, term, classTime /*answer/* // TODO: Define mutator methods - // setInstructorName(), setTerm(), setClassTime() /*answer/* // TODO: Define accessor methods - // getInstructorName(), getTerm(), getClassTime() /*answer/* }
8.8 LAB: Course information (derived classes)
Given main(), define a Course base class with methods to set and get the courseNumber and courseTitle. Also define a derived class OfferedCourse with methods to set and get instructorName, term, and classTime.
Ex. If the input is:
ECE287 Digitalthe output is:
Course Information: Course Number: ECE287 Course Title: Digital Systems Design Course Information: Course Number: ECE387 Course Title: Embedded Systems Design Instructor Name: Mark Patterson Term: Fall 2018 Class Time: WF: 2-3:30 pmimport java.util.Scanner;
public class CourseInformation {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
Course myCourse = new Course();
OfferedCourse myOfferedCourse = new OfferedCourse();
String courseNumber, courseTitle;
String oCourseNumber, oCourseTitle, instructorName, term, classTime;
courseNumber = scnr.nextLine();
courseTitle = scnr.nextLine();
oCourseNumber = scnr.nextLine();
oCourseTitle = scnr.nextLine();
instructorName = scnr.nextLine();
term = scnr.nextLine();
classTime = scnr.nextLine();
myCourse.setCourseNumber(courseNumber);
myCourse.setCourseTitle(courseTitle);
myCourse.printInfo();
myOfferedCourse.setCourseNumber(oCourseNumber);
myOfferedCourse.setCourseTitle(oCourseTitle);
myOfferedCourse.setInstructorName(instructorName);
myOfferedCourse.setTerm(term);
myOfferedCourse.setClassTime(classTime);
myOfferedCourse.printInfo();
System.out.println(" Instructor Name: " + myOfferedCourse.getInstructorName());
System.out.println(" Term: " + myOfferedCourse.getTerm());
System.out.println(" Class Time: " + myOfferedCourse.getClassTime());
}
}
public class Course{
// TODO: Declare private fields - courseNumber, courseTitle
/*answer/*
// TODO: Define mutator methods -
// setCourseNumber(), setCourseTitle()
/*answer/*
// TODO: Define accessor methods -
// getCourseNumber(), getCourseTitle()
/*answer/*
// TODO: Define printInfo()
/*answer/*
}
public class OfferedCourse extends Course {
// TODO: Declare private fields - instructorName, term, classTime
/*answer/*
// TODO: Define mutator methods -
// setInstructorName(), setTerm(), setClassTime()
/*answer/*
// TODO: Define accessor methods -
// getInstructorName(), getTerm(), getClassTime()
/*answer/*
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 1 images
This isn't showing the full Expected Output, how do you get it to print the first course details that show only number & title?