in java: finish the methods for shallow and deep copy public class Book { private String title; private String author; private int numPages; public Book(String title, String author, int numPages){ this.title = title; this.author = author; this.numPages = numPages; } public String getTitle(){ return this.title; } public String getAuthor(){ return this.author; } public int getPages(){return this.numPages; } public void setTitle(String newTitle){ this.title = newTitle; } public void setAuthor(String newAuthor){ this.author= newAuthor;} public void setPages(int numPages){ this.numPages = numPages; } public static void shallowCopyBookArray(Book[] orig, Book[] copy){ // FIX ME } public static void deepCopyBookArray(Book[] orig, Book[] copy){ // FIX ME } public static void main(String[] args) { Book[] books = new Book[6]; books[0] = new Book("The Great Gatsby", "F. Scott Fitzgerald", 180); books[4] = new Book("War of the Worlds", "H.G.Wells", 160); Book[] classics = new Book[6]; //shallowCopyBookArray(books, classics); //deepCopyBookArray(books, classics); } }
in java: finish the methods for shallow and deep copy
public class Book {
private String title;
private String author;
private int numPages;
public Book(String title, String author, int numPages){
this.title = title;
this.author = author;
this.numPages = numPages;
}
public String getTitle(){ return this.title; }
public String getAuthor(){ return this.author; }
public int getPages(){return this.numPages; }
public void setTitle(String newTitle){ this.title = newTitle; }
public void setAuthor(String newAuthor){ this.author= newAuthor;}
public void setPages(int numPages){ this.numPages = numPages; }
public static void shallowCopyBookArray(Book[] orig, Book[] copy){
// FIX ME
}
public static void deepCopyBookArray(Book[] orig, Book[] copy){
// FIX ME
}
public static void main(String[] args) {
Book[] books = new Book[6];
books[0] = new Book("The Great Gatsby", "F. Scott Fitzgerald", 180);
books[4] = new Book("War of the Worlds", "H.G.Wells", 160);
Book[] classics = new Book[6];
//shallowCopyBookArray(books, classics);
//deepCopyBookArray(books, classics);
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 5 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)