A5 ‣ Inheritance

Create a directory named a5 in your repository.  Include in a5 all of the files described below.  Include in each source code file a package declaration.

Write an interface named Course that represents a college course.

  1. The interface should require access methods (getters) for a catalog number (String), title (String), and number of credits (int).

Write a class named TravelCourse that implements the Course interface.

  1. A travel course has a destination (String) along with an access method (getter function) for the field.
  2. The class should set all of its fields in the constructor using arguments passed to the constructor.

Write a class named TravelCourseSection that is a subclass of TravelCourse.

  1. A travel course section has a section number (int) and an instructor (String).
  2. The constructor should set all of the class fields using the values of the arguments passed into the constructor.
  3. The class should have access methods to get the values stored in the fields but should not contain modifier methods.

Write a driver class named Driver that creates two objects of type TravelCourseSection for a 3-credit course numbered FRE-310 with the title Exploring Paris and the destination Paris.

  1. The first object should have section 1 with Smith as instructor.
  2. The second object should have section 2 with Wallace as instructor.
  3. After creating both instances of the TravelCourseSection class, for each instance, print out all of the values of the fields of the instance.

© 2017 – 2019, Eric. All rights reserved.