Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a retail store they are building an order processing system. Each order must have transaction id (long), a transaction date time (Calendar). There are

In a retail store they are building an order processing system. Each order must have transaction id (long), a transaction date time (Calendar). There are two types of other in store order and online order. Each store order also keeps

  • register id, which register was used to process the transaction

  • store location

    The online order has a different set of data requirement. It needs

    • Shipping address

    • Billing address

    • Credit card info

      o Number o Expiremonth o Expireyear

      Each order has one or more order line. Order line contains the following info.

Item Description Quantity Unit price

To support the receipt generator an order must implements the following interface. public interface ReceiptGenerator {

public double receiptTotalAmount(); public String recieptDetails();

}

Your OrderProcessing application class should create one in store order and one online order. Each order should have at least five order line. Then is should make use of the ReceiptGenerator interface to print the receiptTotalAmount and recieptDetails.

  • receiptTotalAmount: should calculate to total amount for the order.

  • recieptDetails: should produce a string from of the entire order details

o all order line for that order o store information if it is a store purchase o shipping address if it is an online purchase

Ok, so this is my assignment. I have all the classes down already and need help in creating a list and the receipt generator part. My teacher told me to do it like this:

ORDER CLASS:

import java.util.ArrayList;

import java.util.Calendar;

import java.util.Date;

import java.util.List;

public class Order {

private int ID;

Date time = Calendar.getInstance().getTime();

public Order(int ID) {

this.ID=ID;

}

public int getID() {

return ID;

}

public void setID(int ID) {

this.ID=ID;

}

List list = new ArrayList();

public void addItem(OrderLine o1, OrderLine o2, OrderLine o3, OrderLine o4, OrderLine o5, OrderLine o6,

OrderLine o7, OrderLine o8, OrderLine o9, OrderLine o10) {

list.add(o1);

list.add(o2);

list.add(o3);

list.add(o4);

list.add(o5);

list.add(o6);

list.add(o7);

list.add(o8);

list.add(o9);

list.add(o10);

}

}

APPLICATION CLASS:

public class Application {

public static void main(String[] args) {

// TODO Auto-generated method stub

Address location = new Address();

location.setStreet("6758 Allisonville Rd");

location.setCity("Indy");

location.setCountry("USA");

location.setZip(46202);

OrderLine o1 = new OrderLine("Milk", 2, 1.39);

OrderLine o2 = new OrderLine("Bread", 1, 1.5);

OrderLine o3 = new OrderLine("Sugar", 1, 1.29);

OrderLine o4 = new OrderLine("Coffee", 2, 3.99);

OrderLine o5 = new OrderLine("Cups", 3, 2.19);

OrderLine o6 = new OrderLine("Pens", 1, 4.99);

OrderLine o7 = new OrderLine("Paper", 1, 2.00);

OrderLine o8 = new OrderLine("Cereal", 2, 3.49);

OrderLine o9 = new OrderLine("Flour", 1, 1.75);

OrderLine o10 = new OrderLine("Batteries", 2, 10.00);

InStore so = new InStore(0, location, 0);

Online em = new Online(location, location, null, 0);

so.addItem(o1);

so.addItem(o2);

so.addItem(o3);

so.addItem(o4);

so.addItem(o5);

em.addItem(o6);

em.addItem(o7);

em.addItem(o8);

em.addItem(o9);

em.addItem(o10);

}

}

HERE ARE THE OTHER CLASSES I CREATED JIC:

ORDERLINE CLASS:

public class OrderLine {

protected String desc;

protected int quant;

protected double price;

public OrderLine(String desc, int quant, double price) {

this.desc = desc;

this.quant = quant;

this.price = price;

}

public String getDesc() {

return desc;

}

public void setDesc(String desc) {

this.desc = desc;

}

public int getQuant() {

return quant;

}

public void setQuant(int quant) {

this.quant = quant;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

}

INSTORE CLASS:

public class InStore extends Order {

protected int RegisterID;

protected Address location;

public InStore(int RegisterID, Address location, int ID) {

super(ID);

this.RegisterID=RegisterID;

this.location=location;

}

public int getRegisterID() {

return RegisterID;

}

public void setRegisterID(int RegisterID) {

this.RegisterID = RegisterID;

}

public Address getLocation() {

return location;

}

public void setLocation(Address location) {

this.location=location;

}

@Override

public String toString() {

return super.toString() + "Register ID=" +RegisterID+ ", Location=" +location;

}

}

ONLINE CLASS:

public class Online extends Order {

protected Address shipping;

protected Address billing;

protected Payment cardInfo;

public Online(Address shipping, Address billing, Payment cardInfo, int ID) {

super(ID);

this.shipping = shipping;

this.billing = billing;

this.cardInfo = cardInfo;

}

public Address getShipping() {

return shipping;

}

public void setShipping(Address shipping) {

this.shipping = shipping;

}

public Address getBilling() {

return billing;

}

public void setBilling(Address billing) {

this.billing = billing;

}

public Payment getcardInfo() {

return cardInfo;

}

public void setcardInfo(Payment cardInfo) {

this.cardInfo = cardInfo;

}

}

PAYMENT CLASS:

public class Payment {

protected int cardNumber;

protected int month;

protected int year;

public Payment (int cardNumber, int month, int year) {

this.cardNumber = cardNumber;

this.month = month;

this.year = year;

}

public int getcardNumber() {

return cardNumber;

}

public void setcardNumber (int cardNumber) {

this.cardNumber = cardNumber;

}

public int getMonth() {

return month;

}

public void setMonth(int month) {

this.month = month;

}

public int getYear() {

return year;

}

public void setYear(int year) {

this.year = year;

}

}

This is due by 11:59 pm tonight so hopefully I can get help before then!!

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

How is a virtual circuit distinguished from other circuits?

Answered: 1 week ago