Given the following data definition class, write one line of Java code that creates one object using
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; 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; } } }
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang