Question

IN JAVA: Design a system for a bookstore that allows the owner to keep track of...

IN JAVA:

Design a system for a bookstore that allows the owner to keep track of the store’s inventory and members. The store sells three types of products: books, CDs, and DVDs. The store offers two

types memberships to customers: regular memberships and premium memberships. The regular membership is free, while the premium members pay a fee every month. For this reason, the

store keeps track of payment method and whether the fee is paid on time for the premium members. The system should keep track of the members and how much money each has spent at

the store. The system also keeps track of the inventory of each product. Inheritance: 1. Member is extended by premium members. 2. Product is sub-classes into books, CDs, and DVDs.

User can select to: add a product, buy a product, display products, display members

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java Progam:

//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;

}

}

//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;

}

}

//Store.java

package bookStore;

import java.util.ArrayList;

import java.util.Scanner;

public class Store {

public static ArrayList<Product> inventory = new ArrayList<Product>();

public static ArrayList<PremiumMember> members = new ArrayList<PremiumMember>();

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

private static void CreateInventory() {

// TODO Auto-generated method stub

int pID, noOfProduct;

String isBook, bISBN;

Book book;

CD cd;

DVD dvd;

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

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

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

isBook = sc.next();

while(true){

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

pID = sc.nextInt();

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

noOfProduct = sc.nextInt();

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

System.out.println("Plese 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);

}

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

// TODO Auto-generated method stub

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

int pID = sc.nextInt();

int pCount;

String premium = null,paymentMethod = null;

double fee = 0;

PremiumMember member;

if(findProduct(pID)){

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

pCount = sc.nextInt();

if(CheckInventory(pID, pCount)){

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

int id = sc.nextInt();

System.out.println("Plese enter Member first Name");

String fName = sc.next();

System.out.println("Plese enter Member last Name");

String lName = sc.next();

System.out.println("Press Y\'y if you member is Premium");

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

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

System.out.println("Enter monthly fee and payment method");

member.setFeeMonthly(fee);

member.setPaymentMethod(paymentMethod);

}

members.add(member);

}

}else{

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

}

}

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

// TODO Auto-generated method stub

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

// TODO Auto-generated method stub

for(Product p:inventory){

if(p.getProductID() == pID)

return true;

}

return false;

}

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

check = sc.next();

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

break;

}

}

}

}

I hope It helps for you!!

Add a comment
Know the answer?
Add Answer to:
IN JAVA: Design a system for a bookstore that allows the owner to keep track of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A database used for a toy store that keeps track of the inventory and purchase orders...

    A database used for a toy store that keeps track of the inventory and purchase orders from the store. All clients will have their membership ID card to shop. This database will help the store to keep track of their orders. It will also help the store to know how many products are available in the inventory. It is necessary to have a membership to purchase a product. The customer can also bring coupons to get discount. Key attributes: Salesman:...

  • A database used for a toy store that keeps track of the inventory and purchase orders...

    A database used for a toy store that keeps track of the inventory and purchase orders from the store. All clients will have their membership ID card to shop. This database will help the store to keep track of their orders. It will also help the store to know how many products are available in the inventory. It is necessary to have a membership to purchase a product. The customer can also bring coupons to get discount. Key attributes: Salesman:...

  • DVD Rental System Develop a DVD/CD Rental System for a shop that rents out DVDs and...

    DVD Rental System Develop a DVD/CD Rental System for a shop that rents out DVDs and VCDs to its registered customers. The system need to keep track of its rental information and compute rental fees collected from DVDs and CDs rented out to customers. This DVD Rental System is to be developed with methods using the Java programming language. The DVD rental shop has several DVDs and CDs, and many customers. Each customer is allowed to rent maximum of five...

  • (JAVA) Using classes and inheritance, design an online address book to keep track of the names

    (JAVA)Using classes and inheritance, design an online address book to keep track of the names, addresses, phone numbers and birthdays of family members, friends and business associates. Your program should be able to handle a maximum of 500 entries.Define the following classes: Class Address to store a street name, city, state and zip code. Class Date to store the day, month and year. Class Person to store a person's last name and first name. Class ExtPerson that extends the class...

  • Sam’s Club, owned bu Wal-Mart, Inc., has been enjoying success in China. Describe the target customer...

    Sam’s Club, owned bu Wal-Mart, Inc., has been enjoying success in China. Describe the target customer for Sam’s Club in the Chinese Market. How does this compare to the target customer for Sam’s Club in the U.S.? SHENZHEN, China—Some foreign businesses have a hard time being as successful in China as they are at home. It’s the opposite for Sam’s Club, the membership chain owned by Wal-Mart Stores Inc. Sam’s Club has struggled in the U.S. to attract higher-income consumers...

  • Question 30 The firms that a company partners with to actively promote and sell a product...

    Question 30 The firms that a company partners with to actively promote and sell a product as it travels through its marketing channel to users are referred to by the firm as its _____. Group of answer choices channel members marketing partners supply members corporate members Question 31 Which of the following is the least risky global entry strategy? Group of answer choices Franchising Joint venture Exporting Direct foreign investment Question 32 Mary ran into a store dedicated to the...

  • Please need serious and professional help! Hello! I am working on an "object oriented analysis and...

    Please need serious and professional help! Hello! I am working on an "object oriented analysis and design" Project. I would really need your sincere help in creating a vision document for this project. The Things That I require in the "vision document" is: 1. Product Overview [This section provides a high level view of the product capabilities, interfaces to other applications, and system configurations. This section usually consists of three subsections, as follows: •          Product perspective •          Product functions •         ...

  • Questions: 1. What trends are happening as it relates to consumer retail purchases, online vs. in-store?...

    Questions: 1. What trends are happening as it relates to consumer retail purchases, online vs. in-store? 2. What challenges do traditional retailers face in trying to transition from in-store sales to online sales? 3. List and briefly describe at least three of the strategies that Target has implemented in its staffing system to better accommodate online sales. 4. What are the career implications of the trends described in this article? 5. From a consumer perspective, what are the relative advantages...

  • Can Technology Save Sears? Sears, Roebuck used to be the largest retailer in the United States, w...

    Can Technology Save Sears? Sears, Roebuck used to be the largest retailer in the United States, with sales representing 1 to 2 percent of the U.S. gross national product for almost 40 years after World War II. Since then, Sears has steadily lost ground to discounters such as Walmart and Target and to competitively priced specialty retailers such as Home Depot and Lowe’s. Even the merger with Kmart in 2005 to create Sears Holding Company failed to stop the downward...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT