I have a class like so:
public abstract class Book {
public abstract double retailPrice();
private String title, author, ISBN;
private double price;
public Book() {
title = "";
author = "";
ISBN = "";
price = 0.00;
}
public Book(String title, String author, String ISBN, double price) {
this.title = title;
this.author = author;
this.ISBN = ISBN;
this.price = price;
}
public String getTitle() {
return title;
}
With objects of a class Textbook (shown below) in an array:
public class Textbook extends Book {
private String course;
@Override
public double retailPrice() {
return super.getPrice() + (super.getPrice() * .10);
}
public Textbook() {
course = "";
}
public Textbook(String course) {
this.course = course;
}
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
}
My array is full of objects such as:
Book[] books = new Book[100];
books[i] = new Textbook(courseName);
When I call my array as using books[i]. the only method available is getTitle() of Textbook's inherited class (Book).
So my question is, how do I get access to the getCourse() function of the Textbook class?