public class Book
{
private String title;
private double price;
public Book( String t, double p )
{
title = t;
price = p;
}
public String getTitle()
{
return title;
}
public String getBookInfo()
{
return title + "-" + price;
}
}
|
Use this Java program to test your answer to the question:
public class Test
{
public static void main(String[] args)
{
Textbook bio2015 = new Textbook("Biology", 49.75, 2);
Textbook bio2019 = new Textbook("Biology", 39.75, 3);
System.out.println(bio2019.getEdition());
System.out.println(bio2019.getBookInfo());
System.out.println(bio2019.canSubstituteFor(bio2015));
System.out.println(bio2015.canSubstituteFor(bio2019));
Textbook math = new Textbook("Calculus", 45.25, 1);
System.out.println(bio2015.canSubstituteFor(math));
}
}
|
The correct answer is:
3 Biology-39.75-3 true false false |
The correct answer is: 63 and 72