Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//Book.java package bookStore; public class Book extends Product{ private String ISBN; public Book(int pID, String bISBN, int noOfProduct) { // TODO Auto-generated constructor stub super(pID,

//Book.java

package bookStore;

public class Book extends Product{

private String ISBN;

public Book(int pID, String bISBN, int noOfProduct) {

// TODO Auto-generated constructor stub

super(pID, noOfProduct);

this.ISBN = bISBN;

}

public String getISBN() {

return ISBN;

}

public void setISBN(String iSBN) {

ISBN = iSBN;

}

}

// CD.java

package bookStore;

public class CD extends Product{

public CD(int pID, int noOfProduct) {

super(pID, noOfProduct);

// TODO Auto-generated constructor stub

}

}

//DVD.java

package bookStore;

public class DVD extends Product{

public DVD(int pID, int noOfProduct) {

super(pID, noOfProduct);

// TODO Auto-generated constructor stub

}

}

//Member.java

package bookStore;

public class Member {

private int id;

private String firstName;

private String lastName;

private double moneySpent;

public Member(int id, String fName, String lName) {

// TODO Auto-generated constructor stub

this.id = id;

this.firstName = fName;

this.lastName = lName;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getFirstName() {

return firstName;

}

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getLastName() {

return lastName;

}

public void setLastName(String lastName) {

this.lastName = lastName;

}

public double getMoneySpent() {

return moneySpent;

}

public void setMoneySpent(double moneySpent) {

this.moneySpent = moneySpent;

}

}

//PremiumMember.java

package bookStore;

public class PremiumMember extends Member {

public PremiumMember(int id, String fName, String lName) {

super(id, fName, lName);

// TODO Auto-generated constructor stub

}

private double feeMonthly;

private String paymentMethod;

private boolean feePaidOnTime;

public double getFeeMonthly() {

return feeMonthly;

}

public void setFeeMonthly(double feeMonthly) {

this.feeMonthly = feeMonthly;

}

public String getPaymentMethod() {

return paymentMethod;

}

public void setPaymentMethod(String paymentMethod) {

this.paymentMethod = paymentMethod;

}

public boolean isFeePaidOnTime() {

return feePaidOnTime;

}

public void setFeePaidOnTime(boolean feePaidOnTime) {

this.feePaidOnTime = feePaidOnTime;

}

}

//Product.java

package bookStore;

public class Product {

private int count;

private int productID;

public Product(int pID, int noOfProduct) {

// TODO Auto-generated constructor stub

this.productID=pID;

this.count = noOfProduct;

}

public int getProductID() {

return productID;

}

public void setProductID(int productID) {

this.productID = productID;

}

public int getCount() {

return count;

}

public void setCount(int count) {

this.count = count;

}

}

//Store.java

package bookStore;

import java.util.ArrayList;

import java.util.Scanner;

public class Store {

public static ArrayList inventory = new ArrayList();

public static ArrayList members = new ArrayList();

public static Scanner sc = new Scanner(System.in);

private static void CreateInventory() {

int pID, noOfProduct;

String isBook, bISBN;

Book book;

CD cd;

DVD dvd;

System.out.println("Press Y if you want to store book in inventory");

System.out.println("Press N if you want to store CD in inventory");

System.out.println("Press NO if you want to store DVD in inventory");

isBook = sc.next();

while (true) {

System.out.println("Please enter product id");

pID = sc.nextInt();

System.out.println("Please enter number of product");

noOfProduct = sc.nextInt();

if (isBook.equalsIgnoreCase("Y")) {

System.out.println("Please enter book ISBN number");

bISBN = sc.next();

book = new Book(pID, bISBN, noOfProduct);

inventory.add(book);

} else if (isBook.equalsIgnoreCase("N")) {

cd = new CD(pID, noOfProduct);

inventory.add(cd);

} else {

dvd = new DVD(pID, noOfProduct);

inventory.add(dvd);

}

System.out.println("Press Y if you want to add another item in the inventory");

System.out.println("Press N if you do not want to add another item in the inventory");

isBook = sc.next();

if (isBook.equalsIgnoreCase("N")) {

break;

}

}

}

private static boolean findProduct(int pID) {

for (Product p : inventory) {

if (p.getProductID() == pID) {

return true;

}

}

return false;

}

private static boolean CheckInventory(int pID, int pCount) {

for (Product p : inventory) {

if (p.getProductID() == pID) {

if (p.getNoOfProducts() >= pCount) {

p.setNoOfProducts(p.getNoOfProducts() - pCount);

return true;

} else {

System.out.println("There are not enough products in the inventory.");

return false;

}

}

}

System.out.println("Product not found in inventory.");

return false;

}

private static void DistributeItem() {

int pID, pCount, id;

String premium = null, paymentMethod = null;

double fee = 0;

PremiumMember member = null;

if (findProduct(pID)) {

pCount = sc.nextInt();

if (CheckInventory(pID, pCount)) {

System.out.println("Please enter member id");

id = sc.nextInt();

System.out.println("Please enter member first name");

String fName = sc.next();

System.out.println("Please enter member last name");

String lName = sc.next();

System.out.println("Press Y if the member is premium");

premium = sc.next();

member = new PremiumMember(id, fName, lName);

if (premium.equalsIgnoreCase("Y")) {

member.setFeeMonthly(fee);

member.setPaymentMethod(paymentMethod);

}

}

}

}

public static void main(String[] args) {

// Create array of Product class

CreateInventory();

while (true) {

// Distribute item from inventory

DistributeItem();

String check;

System.out.println("Do you want to distribute more items? Press Y for Yes or any other key for No");

check = sc.next();

if (!check.equalsIgnoreCase("Y")) {

break;

}

}

}

}

FIX THESE ERRORS BELOW SO THE CODE CAN RUN:

./CD.java:3: error: cannot find symbol public class CD extends Product{ ^ symbol: class Product ./DVD.java:3: error: cannot find symbol public class DVD extends Product{ ^ symbol: class Product ./Store.java:7: error: cannot find symbol public static ArrayList inventory = new ArrayList(); ^ symbol: class Product location: class Store ./Book.java:4: error: cannot find symbol public class Book extends Product{ ^ symbol: class Product ./Store.java:7: error: cannot find symbol public static ArrayList inventory = new ArrayList(); ^ symbol: class Product location: class Store ./Store.java:48: error: cannot find symbol for (Product p : inventory) { ^ symbol: class Product location: class Store ./Store.java:57: error: cannot find symbol for (Product p : inventory) { ^ symbol: class Product location: class Store 7 errors Compilation failed for isted above.

Please provide the update code and the output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions