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

1 Expert Approved Answer
Step: 1 Unlock

Here is the Java code to create an object using the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!