Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package superclass; public class Order { private int OrderID; private String CustomerID; private int ProductID; private String ProductIDWord; private int DateOfOrder; private int OrderAmount; static

image text in transcribed

image text in transcribed

package superclass;

public class Order

{

private int OrderID;

private String CustomerID;

private int ProductID;

private String ProductIDWord;

private int DateOfOrder;

private int OrderAmount;

static int count;

// default Constructor

public Order()

{

this.CustomerID= " No Customer ID";

this.ProductID=0;

this.ProductIDWord=" No Product ID";

this.DateOfOrder=0;

this.OrderAmount=0;

this.OrderID=count++;

}

// non default Constructor

public Order(String CustomerID, int ProductID, String ProductIDWord, int DateOfOrder, int OrderAmount)

{

this.CustomerID=CustomerID;

this.ProductID=ProductID;

this.ProductIDWord=ProductIDWord;

this.DateOfOrder= DateOfOrder;

this.OrderAmount=OrderAmount;

this.OrderID=count++;

}

//Accessor Methods

public String getCustomerID()

{

return this.CustomerID;

}

public int getProductID()

{

return this.ProductID;

}

public String getProductIDWord()

{

return this.ProductIDWord;

}

public int getDateOfOrder()

{

return this.DateOfOrder;

}

public int OrderAmount()

{

return this.OrderAmount;

}

//Mutator Method

public void setCustomerID(String CustomerID)

{

this.CustomerID=CustomerID;

}

public void setProductID(int ProductID)

{

this.ProductID=ProductID;

}

public void setProductIDWord(String ProductIDWord)

{

this.ProductIDWord=ProductIDWordl

}

public void setDateOfOrder(int DateOfOrder)

{

this.DateOfOrder=DateOfOrder;

}

public void setOrderAmount( int OrderAmount)

{

this.OrderAmount=OrderAmount;

}

//ToString Method

public String toString()

{

String word;

word = "the Customer ID is " + this.getCustomerID() + " ";

word = "the Product ID is" + this.ProductID() + " ";

word ="The Product ID Character is" + this.ProductIDWord()+ " ";

word = "The Date of Order is" + this.DateOfOrder() + " ";

word "The Order Amount is" + this.OrderAmount() + " ";

return word;

}

}

package subclass;

import superclass.Order;

public class RepeatedOrder extends Order

{

private int Period;

private int EndDate;

// default Constructor

public RepeatedOrder()

{

this.Period=0;

this.EndDate=0;

}

// non Default Constructor

public RepeatedOrder(String CustomerID, int ProductID, String ProductIDWord, int DateOfOrder, int OrderAmount,int Period, int EndDate)

{

super( CustomerID, ProductID, ProductIDWord, DateOfOrder, OrderAmount);

this.Period=Period;

this.EndDate=EndDate;

}

//Accessor Method

public String getPeriod()

{

return this.Period;

}

public int getEndDate()

{

return this.EndDate;

}

//Mutator Method

public void setPeriod(int Period)

{

this.Period=Period;

}

public void setEndDate(int EndDate)

{

this.EndDate=EndDate;

}

//toString Method

public String toString()

{

word = super.toString();

word = word + "Period" + this.getPeriod() + " ";

word = word + "End Date" + this.getEndDate() + " ";

return word;

}

package client;

import superclass.Order;

import subclass.RepeatedOrder;

public class OrderClient2

{

Order [] orders; // array of objects

int noRecords=0; // no of records, not in the array

// add method to sort the array through increasing date order

public static void main(String [] args)

{

Order myorder = new Order;

String [] clients;

Scanner scan;

String str;

try

{

File myfile = new File("orders.txt");

scan = new Scanner(myfile);

while(scan.hasNextLine())

{

str = scan.nextLine();

String [] tok=str.split(",");

orders= new Order(tok[0],tok[1],Integer.parseInt(tok[2]), Integer.parseInt(tok[3]), Integer.parseInt(tok[4]), Integer.parseInt(tok[5]), Integer.parseInt(tok[6]))

}

scan.close();

catch(IOException ioe)

{

System.out.println("The file can not be read");

}

// User Interactive Part

String option1;

int option2,option3,option4,option5,option6

Scan = new Scanner(System.in);

while(true)

{

System.out.println(" Select an option:");

System.out.println(" Select \"A\" to add an order");

System.out.println("Select \"D\" to delete an order");

System.out.println("Select \"L\" to print out all customer IDs in file");

option1=scan.nextLine();

switch(option1){

case "A" System.out.println("Input Order ID")

option7=scan.nextInt();

System.out.println(" Input Customer Order ID");

option2=scan.nextInt();

System.out.println("Input a Product ID");

option3=scan.nextInt();

System.out.println("Input Date of Order");

option4=scan.nextInt();

System.out.println("Input Order Amount");

option5=scan.nextInt();

for ( int i=0; i

{

myorder.orders[myorders.option2]= orders;

myorder.orders[myorders.option3]= orders;

myorder.orders[myorders.option4]= orders;

myorder.orders[myorders.option5]= orders;

myorder.noRecords++;

}

break;

Case "D" System.out.println(" Please input Order ID);

option2=scan.nextLine();

for ( int i=0; i

{

if ( orders[i].getOrderID() == option7)

{

// for loop, search for input

// if orders[i].getOrderID() == option2

// remove it from the array list

You will design a system to handle office supply orders. A supply order will always have the following attributes Unique order ID (numeric) * Customer ID(alpha) .Product ID(alphanumeric) Date of the order . Order amount Note that there are two types of orders, namely "one-time" or "repeated" order. For "repeated" orders, a supply order also has a period (the number of days between repeats), and an end date for the repeating. Deliverables: Generate a UML diagram in a word doc specifying your design Implement the design and submit the code Identify suitable test cases to test your code and list them in the word doc. . Test Case Output Tested? You will design a system to handle office supply orders. A supply order will always have the following attributes Unique order ID (numeric) * Customer ID(alpha) .Product ID(alphanumeric) Date of the order . Order amount Note that there are two types of orders, namely "one-time" or "repeated" order. For "repeated" orders, a supply order also has a period (the number of days between repeats), and an end date for the repeating. Deliverables: Generate a UML diagram in a word doc specifying your design Implement the design and submit the code Identify suitable test cases to test your code and list them in the word doc. . Test Case Output Tested

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

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

8.1 13

Answered: 1 week ago