Note that there are some explanatory texts on larger screens.

plurals
  1. POSuper & Sub Classes
    primarykey
    data
    text
    <ol> <li><p>this is my application class where i have instead array of objects </p></li> <li><p><code>loanBook</code> is a super class and <code>loanDocumentry</code> is a sub class that extends loanBook. This is declared at the top of the application class</p> <p>public static loanBook[] bookArray = new loanDocumetry[5];</p></li> </ol> <p>then in my application class i have to add new documentry book so i use the scanner for inputs and then use them to add the new object </p> <pre><code>bookArray[i] = new loanDocumentry( title, author, publisher, year, noOfPages, genre); </code></pre> <p>and the book count in <code>loanBook</code> increases so I know each time I run the method it creates new book but when then printing the array out it looks like it never added any of those books to the array and that the only one i have added is the last one </p> <p>Application Class:</p> <pre><code>public class ApplicationClass { public static Scanner input = new Scanner(System.in); public static loanBook[] bookArray = new loanDocumentry[5]; public static void main(String[] args) { addBook(); } public static void addBook() { input.nextLine(); String title; String author; String publisher; int year; int noOfPages; String genre; String choice; int i = 0; System.out.print("\nTITLE of the book: "); title = input.nextLine(); System.out.print("AUTHOR of the book: "); author = input.nextLine(); System.out.print("PUBLISHER of the book: "); publisher = input.nextLine(); System.out.print("YEAR book was published in: "); year = input.nextInt(); System.out.print("NUMBER OF PAGES the book has: "); noOfPages = input.nextInt(); System.out.print("GENRE of the book: "); input.nextLine(); genre = input.nextLine(); bookArray[i] = new loanDocuemntry(title, author, publisher, year, noOfPages, genre); i++; </code></pre> <p>}</p> <p>loanBook Superclass &amp; loanDocumentry Sub class both use set and gets</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload