Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA Design a complete system according to the below requirements.. It Includes: 1) A Class called CandyOrder which stores information about the variety of
IN JAVA
Design a complete system according to the below requirements.. It Includes: 1) A Class called CandyOrder which stores information about the variety of the Candy (such as Snickers), the price per bag/box (such as 2.99), and the amount of bags/boxes (such as 2) ordered. The CandyOrder class should contain a constructor and a default constructor (sets variety to "Snickers", prices to $2.99, and box amount to 1). Accessor and Mutator methods for all instance variables. A toString method returning all instance variable values for this object. An equals method which returns true if variety and price are the same. 2) A Class called MasterOrder: private CandyOrder[] orders; //required instance var /** Constructs a new MasterOrder object. */ public Master Order(int len) {//Constructs array orders (above) with len for length} public boolean addOrder(int spot, String variety, int boxes, double price) { //create a new CandyOrder object and place in position spot in array orders //validate that spot in orders is null and that spot is not >= length of array orders //if validation fails, return false -- else return true } public int getTotalBoxes() {//returns the total of amount of boxes in CandyOrder} public double getTotalCost() {//returns the total cost of all of boxes in CandyOrder} public CandyOrder[] removeVariety(String candyVar) { //removes any object from CandyOrder that has a variety of candyVar, new possible decreased array of CandyOrder (minus candyVars) returned} public String printOutlnfo() {//returns a combined string of all outputs in array orders using toString method in CandyOrder -- seperate each object by a newline 3) Main Driver Class: a) prompt user for the length of the CandyOrder Array desired. b) create a Master Order object passing the length from item a above c) enter the amount of CandyOrders objects required in length via the addOrder method d) call getTotalBoxes to printout total of all boxes e) call getTotalCost to printout total cost of all CandyOrders in array f) call removeVariety on a variety you have in the CandyOrder array in MasterOrder g) call printOutlnfo to printout all info in MasterOrderStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started