Answer To: Assign2.pdf Assign2Test.java Assign2Test.java import java.util.Scanner; /**...
Kshitij answered on Mar 27 2021
Inventory System/Base class/FoodItem.java
Inventory System/Base class/FoodItem.java
/* Created by IntelliJ IDEA.
* Author: Kshitij Varshney (kshitijvarshne1)
* Date: 27-Mar-21
* Time: 12:59 PM
* File: FoodItem.java
*/
package March.mar27_21.BaseClass;
import java.util.Scanner;
public class FoodItem {private int itemCode;
private String itemName;
private float itemPrice;
private int quantityInStock;
private float itemCost;
private String expiryDate;
public FoodItem(int itemCode, String itemName, float itemPrice, int quantityInStock, float itemCost, String expiryDate) {
this.itemCode = itemCode;
this.itemName = itemName;
this.itemPrice = itemPrice;
this.quantityInStock = quantityInStock;
this.itemCost = itemCost;
this.expiryDate = expiryDate;
}
public FoodItem() {
this.itemCode = 0;
this.itemName = null;
this.itemPrice = 0;
this.quantityInStock = 0;
this.itemCost = 0;
this.expiryDate=null;
}
public int getItemCode() {
return itemCode;
}
public void setItemCode(int itemCode) {
this.itemCode = itemCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public float getItemPrice() {
return itemPrice;
}
public void setItemPrice(float itemPrice) {
this.itemPrice = itemPrice;
}
public int getQuantityInStock() {
return quantityInStock;
}
public void setQuantityInStock(int quantityInStock) {
this.quantityInStock = quantityInStock;
}
public float getItemCost() {
return itemCost;
}
public void setItemCost(float itemCost) {
this.itemCost = itemCost;
}
public String getExpiryDate() {
return expiryDate;
}
public void setExpiryDate(String expiryDate) {
this.expiryDate = expiryDate;
}
@Override
public String toString() {
return "itemCode=" + itemCode +
", itemName='" + itemName + '\'' +
", itemPrice= $" + itemPrice +
", quantityInStock=" + quantityInStock +
", itemCost= $" + itemCost +
", expiryDate= " + expiryDate +" , ";
}
public boolean equals(int code) {
return this.getItemCode()==code;
}
public FoodItem addItem(int itemCode){
Scanner sc= new Scanner(System.in);
System.out.println("Enter the name for the item: ");
String itemName = sc.next();
System.out.println("Enter the quantity for the item: ");
int quantityInStock= sc.nextInt();
System.out.println("Enter the cost of the item: ");
int itemCost = sc.nextInt();
System.out.println("Enter the sell price of the item: ");
int itemPrice= sc.nextInt();
System.out.println("Enter the expiry date (yyyy-mm-dd)");
sc.nextLine();
String expiryDate = sc.nextLine();
String finalDate=null;
if(expiryDate.length()!=10){
finalDate="No expiry";
}
else{
finalDate=expiryDate;
}
FoodItem obj = new FoodItem(itemCode,itemName,itemPrice,quantityInStock,itemCost,finalDate);
return obj;
}
}
Inventory System/Base class/FruitItem.java
Inventory System/Base class/FruitItem.java
/* Created by IntelliJ IDEA.
* Author: Kshitij Varshney (kshitijvarshne1)
* Date: 27-Mar-21
* Time: 1:00 PM
* File: FruitItem.java
*/
package March.mar27_21.BaseClass;
import java.util.Scanner;
public class FruitItem extends FoodItem {private String orchardname;
public FruitItem(int itemCode, String itemName, float itemPrice, int quantityInStock, float itemCost, String expiryDate, String orchardname) {
super(itemCode, itemName, itemPrice, quantityInStock, itemCost, expiryDate);
this.orchardname = orchardname;
}
public FruitItem(String orchardname) {
this.orchardname = orchardname;
}
public FruitItem() {
this.orchardname = null;
}
public String getOrchardname() {
return orchardname;
}
public void setOrchardname(String orchardname) {
this.orchardname = orchardname;
}
@Override
public String toString() {
return super.toString()+" orchardname= " + orchardname + " }";
}
public FruitItem addItem(FoodItem obj){
System.out.println("Enter the name of the orchard supplier: ");
Scanner sc= new Scanner(System.in);
this.orchardname = sc.nextLine();
FruitItem ftBucket = new FruitItem(obj.getItemCode(),obj.getItemName(),obj.getItemPrice(),obj.getQuantityInStock(),obj.getItemCost(),obj.getExpiryDate(),this.orchardname);
return ftBucket;
}
}
Inventory System/Base class/Inventory.java
Inventory System/Base...