Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Inventory.java #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions app/src/main/java/com/dineout/code/order/Inventory.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
package com.dineout.code.order;

import java.util.Date;

//Contains details about ingridients ,their status,expiry e.t.c
import java.util.Scanner;

public class Inventory {
public String name;
public Date expiryDate;
public int price;
public int quantity;

// Constructor
public Inventory(String name, Date expiryDate, int price, int quantity) {
this.name = name;
this.expiryDate = expiryDate;
this.price = price;
this.quantity = quantity;
}

// Main method for testing
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Get inventory item details from user
System.out.print("Enter item name: ");
String name = scanner.nextLine();

System.out.print("Enter expiry date (yyyy-mm-dd): ");
String dateInput = scanner.nextLine();
Date expiryDate = java.sql.Date.valueOf(dateInput); // Convert string to Date

System.out.print("Enter price: ");
int price = scanner.nextInt();

System.out.print("Enter quantity: ");
int quantity = scanner.nextInt();

// Create an instance of Inventory
Inventory item = new Inventory(name, expiryDate, price, quantity);

scanner.close(); // Close the scanner
}
}