Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COSC2799 IT Studio 1 2022

Cake Ordering Program

Introduction

Imagine you are working for  a software development company  and are  required to develop an  interactive program to be installed in a     ŬĞďƵƐŝŶĞƐƐ͞ ŬĞƌĞ  ƚŝŽŶƐ͟ . The business makes delicious cakes for all occasions with 1-3 cake layers and offers a variety of flavours .

For this project, your task is split into two parts :

x PART A (see below)

You are given the code skeleton of a Cake class and a CakeInfo class to get started. You are then required to complete the implementation of a list of methods for these two classes (described below).

x PART B (see page 4 of this document)

For this part, you are asked to extend your implementation from Part A to a fully functional program for the cake business .

PART A: The Cake and CakeInfo Class

As a  beginner  programmer,  building a fully functional software system  like an ordering  program for a cake business could be overwhelming and challenging. However, this task can be simplified by applying the concept of abstraction, which is one of the most important concepts in every high-level programming language like Java. In this part of the assignment, you are given the code skeleton of two important classes, i.e., the Cake class and the CakeInfo class. You are required to complete the implementation of a list of methods within these two classes to process the input data and fulfil some essential tasks for the cake ordering system.

Note that in each method, you are allowed to create and call oth er user-defined methods to make the code more readable. However, you should not change the signature of the methods in the code skeleton.

GETTING THE CODE SKELETON

x      Download Code_Skeleton_Rename_this_folder.zip and unzip it into your local folder.

GETTING THE INPUT DATA:

x     After unzipping the code skeleton folder, you will see one ŽĨƚŚĞĨŽůĚĞƌƐŝƐĐĂůůĞĚ͞ĚĂƚĂ͘͟dŚĞ two txt files inside the data folder:

o flavours.txt and price.txt

The Code Skeleton

For Part A, you are provided the code skeleton for:

x     Task 1 [Cake.java] the Cake class. It can be used to construct cakes and contains a list of getter and setter  methods for  its  member variables.  It  also contains  methods that can  display a  cake  in the required format.

x     Task 2 [CakeInfo.java] the CakeInfo class. It contains methods to extract and process price information from the txt files, as well as the method to calculate the unit price of a cake.

x      [PartATesting.java] this is a simple testing class that helps you to develop some test cases to test your implementation.

Task 1: The Cake class

The Cake class can be used to construct cakes and can display a cake in the required format. The Cake class has the following instance variables:

flavour is a String type variable storing the flavour of the entire cake

noOfLayers is an int type variable storing the number of layers of the cake

price is a float type variable storing the price/cost of the cake

dietaryReq is a String type variable storing any dietary requirements for the cake

Task 1.1 toString

The code skeleton has been given for the Cake class, where the constructor, and a list of getter and setter methods have been implemented. In this task, you are required to implement the toString() method that displays the cake in the required format. For instance, for a 3-layer cake that has the flavour lemon yoghurt with no dietary requirements, with a cost of 100 dollars, the toString() method should return the String format of the Cake item as follows:

Order: 3-layer lemon yoghurt cake Dietary requirements: None Cake Price: $100.00

where the number of layers is    ƌŵĂƚƚĞĚĂƐ͞ϭ-layer or 2-layer or 3- ůĂLJĞƌ͟ ůů  ǁĞĚďLJƚŚĞ ůĂǀ  Ƶƌ and dietary requirements . This is followed by the Cake Price with the cost and a dollar sign prefix, price showing 2 decimal places. Note there are three whitespaces in between the cake order, dietary requirements and cake price.

Task 2 The CakeInfo class

The CakeInfo class contains methods to load, extract, and process price information from the txt files, as well as the method to calculate the unit price of a given cake. The CakeInfo class contains the following variables and methods:

⃞     flavoursInfoFile is a String variable used to store the pre-defined file path of the flavours.txt file. ⃞     priceInfoFile is a String variable used to store the pre-defined file path of the price.txt file.           ⃞     flavoursInfo is a 2D String array used to store flavours information as in flavours .txt.

⃞      priceInfo is a 2D float array consisting of 3 rows and 3 columns used to store price information as in

price_info.txt.

The code skeleton for the CakeInfo class has been given to you, with the above mentioned variables and a list of method  signatures.  You  are  required  to  complete  the  implementation  in  places  as  indicated  in  the  code comments.

In the first two tasks, you are required to load the provided data file, extract and store the data in flavoursInfo and priceInfo accordingly. Then, you will need to complete the implementation of the method to calculate the price for a given cake.

Task 2.1 loadFlavours

In  this  task,  you  are  required  to  implement  the  loadFlavours  method.  This  method  takes  a  String flavoursInfoFile as input (i.e., the input file path for flavours.txt), it then reads the file, extracts the data and stores the flavour information into its variable flavoursInfo as per requirement below:

x      flavoursInfo is a 2D array consisting of 9 rows and 5 columns.

o  Each row corresponds to a flavour category, row in index 0 corresponds to Chocolate 1, ......, index 8 corresponds to Special 9.

o  Columns of each row are used to store the list of specific flavours belonging to each flavour category corresponding to the row. We assume the maximum number of specific flavours in a flavour category is 5. Depending on the number of flavours listed in a flavour category, each element in the array is used to store a specific flavour, or an empty string ͟͞;ŝ ƚŚĞŶƵŵďĞƌ specific flavours in that flavour category is less than 5).

Task 2.2 loadPriceInfo

In  this  task,  you  are  required  to  implement  the  loadPriceInfo  method.  This  method  takes  a  String priceInfoFile as input (i.e., the input file path for price_info.txt), it then reads the file, extracts the data, and stores the price information into its variable priceInfo as per requirement below:

x     priceInfo is a 2D array consisting of 3 rows and 3 columns. Each element in the array is used to store the price value for each cake depending on the number of cake layers. This is specified by row index where a specific flavour falls in a particular flavour category which will determine which corresponding column index it belongs to.

x      More details about the 2D array: (Tip: Read this while inspecting the data in flavours.txt and price.txt)

o  Each row corresponds to the price depending on the number of layers of the cake .

ƒ Row in index 0 corresponds to 1 Layer

ƒ Row in index 1 corresponds to 2 Layers

ƒ Row in index 2 corresponds to 3 Layers

o  In  each  row,  each  column  corresponds to  a  price  range depending on which flavour category it belongs to.

o  Similar to the file format (mentioned in Part A)

ƒ Column index 0 corresponds to the cheapest flavou rs:

x      Chocolate 1, Vanilla 2, and Lemon 5

ƒ Column index 1 corresponds to the mid-range priced flavours:

x      Caramel 3, Banana 4, and Coffee 7

ƒ Column index 2 corresponds to the most expensive flavours:

x      Tea 6, Exotic 8, and Special 9

o Task 2.3 calCakePrice

In this task, you are required to implement the calCakePrice method. This method takes a cake (i.e., object of Cake class) as input, calculates the price of the cake based on its number of layers and flavour, and returns the price value (float). Hint: to be able to calculate the price value of a cake, you will have to search for the corresponding flavour category based on the specific flavour that the customer chose .

Task 3 Testing of your developed functions

Once you  have  completed  the  implementation  of  a  function, thorough testing  is  necessary to verify your implementation. There are two benefits to testing. The first benefit is that testing will reveal the possible bugs in your code and check your understanding of the requirements . Secondly, if the code is changed for some ĂƐŽŶ;ƐƵĐŚĂƐĐŽĚ ĨĂĐƚŽ ŝŶŐ͕ĂĚĚŝŶŐŶ  ǁĨ  ĂƚƵ    Ɛ ƚĐͿ͕ƚ  ƐƚŝŶŐǁŝůůŐƵĂ ĂŶƚ ƚŚ ĐŚĂŶŐ ǁŽŶ͛ƚƵŶĚ    ŵŝŶ   your original logic and still satisfy the original requirements that needed to be maintained. The following is a general procedure for testing:

⃞      according to the requirement, prepare your testing values to cover all the possibilities of input of your

function such as normal condition, boundary condition/special case etc.

⃞      for each testing value, predict your expected value regardless of your implementation, by referring to

the requirement.

⃞     Generate the actual outputs of your program by invoking/calling your functions for each testing value ⃞     Finally, compare your expected value and the actual output, if the actual output matches the expected

value,  it  gives  you   peace  of  mind.  Otherwise,  either  your  expected  value  is   wrong,  or  your implementation  is  not  flawless.  If  that  occurs,  check  either  both  the  expected  value  and  your implementation to figure out the problem.

For example, when testing the calCakePrice method, for a 1-layer banana foster cake, the expected return value is 40.0. This is because banana foster belongs to the ͞Banana 4͟ flavour category which is a mid-range priced flavour. According to price.txt, 1 Layer mid-range priced flavours corresponds to 40.0.

The actual output will be the value returned by invoking the calCakePrice method with the cake described above. If the actual value is also 40.0, this test case is passed, otherwise, there might be bugs in your code.

Note that adding one testing value is not enough to cover all the scenarios. More test cases are needed for thorough testing.

In order to assist your understanding of the required functionality, a simple testing class PartATesting is provided for you and the test case described above has also been included. However, in this task, you are required to design other test values and further test the functions you have developed.

Part B: Cake ordering program

In this part, you will  be given a  list of functional  requirements for the cake ordering  program. You will then continue to develop the cake ordering program, and extend the work you did in Part A.

Note that your program should support continuous orders. If you demand the next user to restart the program each time they shop, your program does not fulfil this requirement. However, you can assume that it only serves one customer at a time, i.e., the next customer will only start shopping after the previous customer checks out or cancels their shopping.

It is up to you to decide *how * to implement Part B. Additional skeleton code will not be given.

Task 1 ʹ Functionality

This program should provide the following functionalities, as expected for a cake ordering program.

[Function 1] Order a cake

Your program should allow the user to order one cake at a time and add this to his/her shopping cart.        A flavour which is not found should be categorised as an expensive flavour. Any value entered by the user which is outside of the range 1-3 for layers, will be priced as a 3-layer cake.

Optional: Display all the possible 32 cake flavours they can choose from on the menu .

[Function 2] View shopping cart

Users should be able to view their shopping cart. Once requested, your program should print out the list of cakes and each of its individual costs, as well as the total cost of the cakes in the shopping cart.

[Function 3] Amend a cake

Your program should allow the user to amend a cake in the shopping cart to change a ŽĨ ƚŚĞ ĐĂŬĞ͛Ɛ attributes. Users need to re-enter all the cake attributes to amend it. For example, even though they just want to  amend the  number  of  layers, they would  also  need to  re-enter the same flavour and  dietary requirements that they need.

[Function 4] Remove a cake

Your program should allow the user to delete a cake in the shopping cart. It should ask the users to confirm the deletion before removing a cake from the cart.

[Function 5] Checkout

Once a customer chooses to check out, the program should present one additional option:

x     Add a special candle which will add $10.50 to their total cost (limited to 1 candle maximum per customer)

Your program should also ask for the following details from the customer :

x      Delivery address

The program should print out the invoice along with a list of purchased cakes to a .txt file.  This file should have a unique name, indicating the order date and time (see the example in the following screenshot). One .txt file should  be  produced for  every  customer  upon  checkout.  Since your  program  needs to support continuous orders, the second customer does not need to restart the program to order. Once the second customer has checked out, a new .txt file will be produced. The format of the invoice should look like the following screenshot :

Task 2 - USER MANUAL

You are required to provide the user manual for Part B of your program. This will give users full information about how to run and use the program which you have developed.