Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FIX THE CODE SO THE PROGRAM WILL COMPILE AND RUN WITHOUT ANY ERRORS!!! FIX THE CODE SO THE PROGRAM WILL COMPILE AND RUN WITHOUT ANY

FIX THE CODE SO THE PROGRAM WILL COMPILE AND RUN WITHOUT ANY ERRORS!!!

FIX THE CODE SO THE PROGRAM WILL COMPILE AND RUN WITHOUT ANY ERRORS!!!

image text in transcribed

Book.java

package bookStore;

public class Book extends Product { private String ISBN;

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

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); } }

DVD.java

package bookStore;

public class DVD extends Product { public DVD(int pID, int noOfProduct) { super(pID, noOfProduct); } }

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) {

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 { private double feeMonthly; private String paymentMethod; private boolean feePaidOnTime;

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

super(id, fName, lName);

}

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) {

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;

while (true) {

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 O if you want to store DVD in inventory");

isBook = sc.next();

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 if (isBook.equalsIgnoreCase("O")) {

dvd = new DVD(pID, noOfProduct);

inventory.add(dvd);

}

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

char ch = sc.next().charAt(0);

if (ch != 'Y' && ch != 'y') {

break;

}

}

}

private static void distributeItem() {

System.out.println("Enter product id to issue");

int pID = sc.nextInt();

int pCount;

String premium;

PremiumMember member;

if (findProduct(pID)) {

System.out.println("Enter number of items you want");

pCount = sc.nextInt();

if (checkInventory(pID, pCount)) {

System.out.println("Please enter Member ID");

int 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")) {

System.out.println("Enter monthly fee");

double fee = sc.nextDouble();

System.out.println("Enter payment method");

String paymentMethod = sc.next();

member.setFeeMonthly(fee);

member.setPaymentMethod(paymentMethod);

}

members.add(member);

}

} else {

System.out.println("Item not found");

}

}

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

for (Product p : inventory) {

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

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

p.setCount(p.getCount() - pCount);

return true;

}

}

}

return false;

}

private static boolean findProduct(int pID) {

for (Product p : inventory) {

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

return true;

}

}

return false;

}

public static void main(String[] args) {

createInventory();

while (true) {

distributeItem();

System.out.println("Do you want to distribute more items press Y")

check = sc.next();

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

break;

}

}

}

}

Your project must contain the following classes (at minimum): - Book CD - DVD - Member - PremiumMember - Bookstore Part A - UML Diagram and Feature Description Examine the description of the system above. Using one of the UML Diagramming tools (5ee Course Resources), design the different classes of your system. Think of the various things (objects) that you need to represent in the system and what properties they need to have and actions to perform. For now we don't need to worry about relationships between the classes. We will add that in a later project. Your diagram must show: - All of the classes, nelds, and methods. Remember that you will need methods that accomplish appropriate functionality, not just getters and setters. - You must include visibility (i.e., public or private), data types, return types, and any other pertinent information. - Show the data types/structures (e.g., 5 trings, arrays or ArrayLists, Book, ...) that your program will use to hold the important data. In addition, you should also submit a document that describes the 3 functions your system will implement. This description should include any arguments, returns, or nelds needed in order to make this functionality work. 5 save the description in a fle (flle format can be text, pdi or doc) with the name Bookstoredesign. Part B - Implementation and Test Harness - Create and write your project in the appropriate CodingRooms assignment - Create all of the classes you mapped out in the UML diagram from Part A. - A dd all the nelds and methods described in your UML, including getters/setters/constructors. - Your project and its contents should match your UML exactly. If you name a method in the UML, I will expect to see it in the CodingRooms project. Note that you can complete this step in its entirety before adding any functionality. You can use empty stub methods to start. - Now you need to add enough code and logic to your methods to implement the "complete a purchase" functionality and create a test harness so this function can be executed. In order to test your functionality, you should create a Test Harness class. This should be a separate class titled TestHarness. This will be a class whose function is to create an object that represents the book store, and use 5 canner objects to take input and direct the user through the system. For clues as to how this can be accomplished, look back at labs like the BurgerOrder project. Text menus should be presented to the user that will allow them to pick from options such as "Make a purchase" or "Create a new member". For options that are not implemented you can simply print a message and redisplay the menu options. This should be the only class that includes a main method

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago