the Dean\'s office. Minimal Submitted Files You ae ropuired. bu not e,ot st Assi
ID: 3884746 • Letter: T
Question
the Dean's office. Minimal Submitted Files You ae ropuired. bu not e,ot st Assignment4.java (Download this file and use it as your driver program for this assignment) Book.java Publication.java Requirements to get full credits in Documentation The assignment number, your name, StudentID, Lecture number(time), and a class description need to be included at the top of each file/class A description of each method is also needed. Some additional comments inside of methods (especially for a "main" method) to explain code that are hard to follow should be written. You can look at the Java programs in the textbook to see how comments are added to programs Skills to be Applied In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed: Classes Instance Objects Accessors/Mutators (Modifiers) methods Visibility Modifiers (Access specifier) public, private, etc. Encapsulation concept Aggregation relationship between classesExplanation / Answer
Publication.java:
public class Publication {
private String ISBN;
private int version;
private double price;
public Publication() {
ISBN = "?";
this.version = 1;
this.price = 0.0;
}
public String getISBN() {
return ISBN;
}
public int getVersion() {
return version;
}
public double getPrice() {
return price;
}
public void setISBN(String iSBN) {
ISBN = iSBN;
}
public void setVersion(int version) {
this.version = version;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String toString() {
return "Edition: " + version + " ISBN: " + ISBN + " Price: $" + price + " ";
}
}
Book.java:
public class Book {
private String title;
private String author;
private Publication publication;
public Book() {
this.title = "?";
this.author = "?";
this.publication = new Publication();
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public Publication getPublication() {
return publication;
}
public void setTitle(String title) {
this.title = title;
}
public void setAuthor(String author) {
this.author = author;
}
public void setPublication(int newVersion, String newISBN, double newPrice) {
this.publication.setISBN(newISBN);
this.publication.setVersion(newVersion);
this.publication.setPrice(newPrice);
}
@Override
public String toString() {
return " Title: " + title + " Author: " + author + " "
+ publication + " ";
}
}
Please use the above classes with your assignment.java file.. they will work.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.