//******************************************************************** // Textbook.java Author: yourname // // Represents a textbook - with a title, author and edition number. //******************************************************************** import java.text.NumberFormat; public class Textbook { private static int bookcount = 0; // counts the number of books private static double value = 0; // keeps the total value of all books private String title; private String author; private int edition; private double price; private boolean used; public Textbook(String title, String author, int edition, double price, boolean used) { this.title = title; this.author = author; this.edition = edition; this.price = price; this.used = used; bookcount++; value += price; } public void discount(double percent) { double disc = price * percent; price = price - disc; value = value - disc; } public void discount() { double disc; if (used) disc = price * .12; else disc = price * .07; price = price - disc; value = value - disc; } public static int getCount() { return bookcount; } public static double getValue() { return value; } public String toString() { NumberFormat money = NumberFormat.getCurrencyInstance(); return title + " by " + author + ", edition " + edition + (used?" USED ":" NEW ") + money.format(price); } }