Note that there are some explanatory texts on larger screens.

plurals
  1. POstuck on creating a new object
    primarykey
    data
    text
    <p>I am trying to create a new object called item1, which belongs to the StockItem class. I have already created the constructor for a StockItem inside the class file, making all the variables public, however i am now trying to create a new instance of it, but want the variables to be entered by a user, using the scanner class.</p> <p>How would i go about creating a new instance of my objec? I have created the scanner class too, and got it to read input, but not recognise that the input i am typing is an attribute of a new item.</p> <p>Any help would be much appreciated please, thanks.</p> <pre><code>StockItem Constructor: public StockItem (String itemID, String itemDesc, Double price, int quantity, int reOrderLevel) { this.itemID = itemID; this.itemDesc = itemDesc; this.price = price; this.quantity = quantity; this.reOrderLevel = reOrderLevel; } </code></pre> <p>Code for scanner input:</p> <pre><code>else if (i==1) { StockListInterface.doAddItem(item); System.out.println("Add New Item"); System.out.println("****************"); Scanner scanner1 = new Scanner(System.in); System.out.println("Enter ID :&gt;"); String itemID = scanner1.nextLine(); System.out.println("Enter Description :&gt;"); String itemDesc = scanner1.nextLine(); System.out.println("Enter Price :&gt;"); String price = scanner1.nextLine(); System.out.println("Enter Quantity :&gt;"); String quantity = scanner1.nextLine(); System.out.println("Enter Re-Order Level :&gt;"); String reOrderLevel = scanner1.nextLine(); System.out.println("Enter another? (Y/N) :&gt;"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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