Class Design Within the backend server, we’ll have multiple classes to organize our code. All the class descriptions are listed below. FoodWastageRecord NOTE: You need to design this class. It represents each food wastage entry recorded by the user through the form on the webpage (frontend). If you notice the form on the webpage, you’ll see that each FoodWastageRecord will have the following as the data members aka member variables. Date (as string) Meal (as string) Food name (as string) Quantity in ounces (as double) Wastage reason (as string) Disposal mechanism (as string) Cost (as double) Each member variable comes with its accessor/mutator functions. FoodWastageReport NOTE: You need to design this class. It represents the report generated on the basis of the records entered by the user. This class will be constructed with all the records entered by the user as a parameter. It will then apply the logic to go over all the records and compute the following: Names of most commonly wasted foods Most costly waste producing meals Total cost of food wasted Most common reasons of food wastage Most common mechanisms of food disposal Suggested strategies to reduce food waste Your class should have getter functions to retrieve each of the above. FoodWastageTracker NOTE: You need to design this class. It’ll hold all the FoodWastageRecord objects in memory (notice the has-a relationship between the FoodWastageTracker class and FoodWastageRecord class in the diagram above). It’ll allow the user to Add a FoodWastageRecord to the list of records in memory. IT SHOULD NOT add duplicate records. Return true if the record was added successfully, else return false. Delete a FoodWastageRecord from memory. Return true if the record was actually deleted. Return false if the record to be deleted wasn’t found. [NOTE: This is an extra credit requirement.] Get all FoodWastageRecord objects from memory Generate and return the FoodWastageReport All four of these will be the member functions of your class. FoodWastageTrackerBackend The top level class in the backend server is the FoodWastageTrackerBackend class. Most of the implementation of this class has already been provided to you as part of the starter code. Think of this class as an adapter between the frontend and the code that you are going to write. It encapsulates all the complexity around interacting with the frontend, reading food wastage records from the JSON file and writing food wastage records to the JSON file.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Class Design
Within the backend server, we’ll have multiple classes to organize our code.
All the class descriptions are listed below.
FoodWastageRecord
NOTE: You need to design this class.
It represents each food wastage entry recorded by the user through the form on the webpage (frontend).
If you notice the form on the webpage, you’ll see that each FoodWastageRecord will have the following as the data members aka member variables.
- Date (as string)
- Meal (as string)
- Food name (as string)
- Quantity in ounces (as double)
- Wastage reason (as string)
- Disposal
mechanism (as string) - Cost (as double)
Each member variable comes with its accessor/mutator functions.
FoodWastageReport
NOTE: You need to design this class.
It represents the report generated on the basis of the records entered by the user. This class will be constructed with all the records entered by the user as a parameter. It will then apply the logic to go over all the records and compute the following:
- Names of most commonly wasted foods
- Most costly waste producing meals
- Total cost of food wasted
- Most common reasons of food wastage
- Most common mechanisms of food disposal
- Suggested strategies to reduce food waste
Your class should have getter functions to retrieve each of the above.
FoodWastageTracker
NOTE: You need to design this class.
It’ll hold all the FoodWastageRecord objects in memory (notice the has-a relationship between the FoodWastageTracker class and FoodWastageRecord class in the diagram above).
It’ll allow the user to
- Add a FoodWastageRecord to the list of records in memory. IT SHOULD NOT add duplicate records. Return true if the record was added successfully, else return false.
- Delete a FoodWastageRecord from memory. Return true if the record was actually deleted. Return false if the record to be deleted wasn’t found. [NOTE: This is an extra credit requirement.]
- Get all FoodWastageRecord objects from memory
- Generate and return the FoodWastageReport
All four of these will be the member functions of your class.
FoodWastageTrackerBackend
The top level class in the backend server is the FoodWastageTrackerBackend class. Most of the implementation of this class has already been provided to you as part of the starter code. Think of this class as an adapter between the frontend and the code that you are going to write. It encapsulates all the complexity around interacting with the frontend, reading food wastage records from the JSON file and writing food wastage records to the JSON file.
Step by step
Solved in 4 steps