Question
Given the following data definition class, write one line of Java code that creates one object using the default constructor publicclassBook { privateString isbn; privatedoublecost;
Given the following data definition class, write one line of Java code that creates one object using the default constructor
publicclassBook { privateString isbn; privatedoublecost; privatebooleanisNew; publicBook() { this.isNew =true; } publicBook(String isbn) { this(); this.isbn = isbn; } publicBook(String isbn,doublecost) { this(); this.isbn = isbn; this.cost = cost; } publicString getIsbn() {returnthis.isbn; } publicdoublegetCost() {returnthis.cost; } publicbooleanisNew() {returnthis.isNew; } publicvoidsetIsbn(String isbn) { this.isbn = isbn; } publicbooleansetCost(doublecost) { if(cost >= 0) { this.cost = cost; returntrue; } else{ returnfalse; } } publicvoidsetIsNew(booleanisNew) { this.isNew = isNew; } publicbooleandiscount(doublepercentage) { if(percentage > 0) { setCost(this.getCost() -this.getCost() * (percentage/100)); returntrue; } else{ returnfalse; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here is the Java code to create an object using the ...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