Homework Solution: Programming Problem 3 – Book…

    Programming Problem 3 - Book A Book has such properties as titleauthor, and numberOfPages. A Volume will have properties such as volumeNamenumberOfBooks, and an array of book objects (Book [ ]). You are required to develop the Book and Volume classes, then write an application (DemoVolume) to test your classes. The directions below will give assistance. Create a class called Book with the following properties using appropriate data types: Title, Author, numberOfPages, Create a second class called Volume with the following properties using appropriate data types: volumeName, numberOfBooks and Book [ ]. The Book [ ] contains an array of book objects. Directions Create a class called Book with the following properties using appropriate data types: Title, Author, numberOfPages, The only methods necessary in the Book class, for this exercise, are the constructor and a toString(). Create a second class called Volume with the following properties using appropriate data types:volumeNamenumberOfBooks and Book [ ]. Book [ ] will contain an array of book objects. The only methods necessary in the Volume class, for this exercise, are the constructor, toString() and getBookArray(). The getBookArray returns a string of book properties for each book. Create an application called DemoVolume.In the main method, Create an array of book objects to be added to the volume. Create a volume object called volume1. Display the properties of volume1.

    Expert Answer

     
    DemoVolume.java public class DemoVolume

    Programming Problem 3 – Capacity

    Book has such properties as titleauthor, and numberOfPages. A Volume obtain possess properties such as volumeNamenumberOfBooks, and an place of capacity appearances (Capacity [ ]). You are required to lay-open the Capacity and Quantity adjustes, then transcribe an application (DemoVolume) to touchstone your adjustes. The directions under obtain yield coadjutorship.

    Create a adjust determined Capacity with the controlthcoming properties using alienate basis types: Appellation, Creator, numberOfPages, Create a assist adjust determined Quantity with the controlthcoming properties using alienate basis types: quantityName, numberOfBooks and Capacity [ ]. The Capacity [ ] includes an place of capacity appearances.

    Directions

    Create a adjust determined Capacity with the controlthcoming properties using alienate basis types: Appellation, Creator, numberOfPages,

    The singly regularitys requisite in the Capacity adjust, control this employment, are the fabricator and a toString().

    Create a assist adjust determined Quantity with the controlthcoming properties using alienate basis types:volumeNamenumberOfBooks and Capacity [ ]. Capacity [ ] obtain include an place of capacity appearances.

    The singly regularitys requisite in the Quantity adjust, control this employment, are the fabricator, toString() and getBookArray(). The getBookPlace receipts a string of capacity properties control each capacity.

    Create an application determined DemoVolume.In the ocean regularity,

    Create an place of capacity appearances to be pretended to the quantity.

    Create a quantity appearance determined quantity1.

    Display the properties of quantity1.

    Expert Rejoinder

     

    DemoVolume.java

    public adjust DemoVolume

    {

    public static unoccupied ocean (String[] args)

    {

    Book[] capacitys=new Capacity[3];

    books[0]=new Capacity(“God of Antarctica”, “shukla”, 450);

    books[1]=new Capacity(“Wings of fire”,”kalam”, 850);

    books[2]=new Capacity(“Walking with giants”,”ramachandran”, 750);

    Quantity quantity1=new Quantity(“Volume1”,3,books);

    System.out.println(volume1);

    }

    }

    adjust Capacity{

    String creator;

    String appellation;

    int noOfPages;

    Book(String appellation,String creator, int noOfPages){

    this.author=author;

    this.title=title;

    this.noOfPages=noOfPages;

    }

    public String toString(){

    return “Title=”+title+” Creator=”+author+” No of Pages=”+noOfPages;

    }

    }

    adjust Quantity{

    String quantityName;

    int noOfBooks;

    Book[] capacitys;

    Volume(String quantityName,int noOfBooks,Book[] capacitys){

    this.volumeName=volumeName;

    this.noOfBooks=noOfBooks;

    this.books=books;

     

    }

    public String getBookArray(){

    String string=”Books:n”;

    for(int i=0;i<noOfBooks;i++){

    string+=books[i]+”n”;

    }

    return string;

    }

    public String toString(){

    return “Quantity Name:”+volumeName+”n”+

    “No of Capacitys:” +noOfBooks+”n”+

    getBookArray();

    }

    }

    Output: