Question
Consider the data definition class identified below. Using terminology learned in the course, briefly (1-2 sentences) explain the purpose of the line of code that
Consider the data definition class identified below. Using terminology learned in the course, briefly (1-2 sentences) explain the purpose of the line of code that states: this();
public class Book { private String isbn; private double cost; private boolean isNew; public Book() { this.isNew = true; } public Book(String isbn) { this(); this.isbn = isbn; } public Book(String isbn, double cost) { this(); this.isbn = isbn; this.cost = cost; } public String getIsbn() { return this.isbn; } public double getCost() { return this.cost; } public boolean isNew() { return this.isNew; } public void setIsbn(String isbn) { this.isbn = isbn; } public boolean setCost(double cost) { if (cost >= 0) { this.cost = cost; return true; } else { return false; } } public void setIsNew(boolean isNew) { this.isNew = isNew; } public boolean discount(double percentage) { if (percentage > 0) { setCost(this.getCost() - this.getCost() * (percentage/100)); return true; } else { return false; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Answer this method function It is used to call the constructor of the current class Note 1 You can o...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started