Need Help fixing my code!! only under TODO's. // Util function to convert a FoodWastageReport class object into a serialized // JSON object. crow::json::wvalue FoodWastageReportToCrowJSON(     const FoodWastageReport &report) {   crow::json::wvalue report_json({});   std::vector most_common_disposal_mechanisms{};   // TODO 1: Call the member function of FoodWastageReport class that returns   // all the most common disposal mechanisms as a vector of strings. Store the   // result in the vector declared above.   FoodWastageReport report;   std::vector most_common_disposal_mechanisms = report.MostCommonDisposalMechanisms();   report_json["most_common_disposal_mechanism_"] =       most_common_disposal_mechanisms;   std::vector most_commonly_wasted_foods{};   // TODO 2: Call the member function of FoodWastageReport class that returns   // all the most commonly wasted foods as a vector of strings. Store the result   // in the vector declared above.   std::vector most_commonly_wasted_foods = report.MostCommonlyWastedFoods();   report_json["most_commonly_wasted_food_"] = most_commonly_wasted_foods;   std::vector most_common_wastage_reasons{};   // TODO 3: Call the member function of FoodWastageReport class that returns   // all the most commonwastage reasons as a vector of strings. Store the result   // in the vector declared above.   std::vector most_common_wastage_reasons = report.MostCommonWastageReasons();   report_json["most_common_wastage_reason_"] = most_common_wastage_reasons;   std::vector most_costly_waste_producing_meals{};   // TODO 4: Call the member function of FoodWastageReport class that returns   // all the most costly waste producing meals as a vector of strings. Store the   // result in the vector declared above.   std::vector most_costly_waste_producing_meals = report.MostCostlyWasteProducingMeals();   report_json["most_waste_producing_meal_"] = most_costly_waste_producing_meals;   std::vector suggested_strategies_to_reduce_waste{};   // TODO 5: Call the member function of FoodWastageReport class that returns   // all the suggested strategies as a vector of strings. Store the result in   // the vector declared above.   std::vector suggested_strategies_to_reduce_waste = report.SuggestWasteReductionStrategies();   report_json["suggested_strategies_to_reduce_waste_"] =       suggested_strategies_to_reduce_waste;   double total_cost_of_wastage = -9999.0;

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter6: Working With Tables And Columns: Creating A Program Schedule For A Radio Station
Section: Chapter Questions
Problem 8CP2
icon
Related questions
icon
Concept explainers
Question

Need Help fixing my code!! only under TODO's.

// Util function to convert a FoodWastageReport class object into a serialized
// JSON object.
crow::json::wvalue FoodWastageReportToCrowJSON(
    const FoodWastageReport &report) {
  crow::json::wvalue report_json({});

  std::vector<std::string> most_common_disposal_mechanisms{};
  // TODO 1: Call the member function of FoodWastageReport class that returns
  // all the most common disposal mechanisms as a vector of strings. Store the
  // result in the vector declared above.
  FoodWastageReport report;
  std::vector<std::string> most_common_disposal_mechanisms = report.MostCommonDisposalMechanisms();
  report_json["most_common_disposal_mechanism_"] =
      most_common_disposal_mechanisms;

  std::vector<std::string> most_commonly_wasted_foods{};
  // TODO 2: Call the member function of FoodWastageReport class that returns
  // all the most commonly wasted foods as a vector of strings. Store the result
  // in the vector declared above.
  std::vector<std::string> most_commonly_wasted_foods = report.MostCommonlyWastedFoods();
  report_json["most_commonly_wasted_food_"] = most_commonly_wasted_foods;

  std::vector<std::string> most_common_wastage_reasons{};
  // TODO 3: Call the member function of FoodWastageReport class that returns
  // all the most commonwastage reasons as a vector of strings. Store the result
  // in the vector declared above.
  std::vector<std::string> most_common_wastage_reasons = report.MostCommonWastageReasons();
  report_json["most_common_wastage_reason_"] = most_common_wastage_reasons;

  std::vector<std::string> most_costly_waste_producing_meals{};
  // TODO 4: Call the member function of FoodWastageReport class that returns
  // all the most costly waste producing meals as a vector of strings. Store the
  // result in the vector declared above.
  std::vector<std::string> most_costly_waste_producing_meals = report.MostCostlyWasteProducingMeals();
  report_json["most_waste_producing_meal_"] = most_costly_waste_producing_meals;

  std::vector<std::string> suggested_strategies_to_reduce_waste{};
  // TODO 5: Call the member function of FoodWastageReport class that returns
  // all the suggested strategies as a vector of strings. Store the result in
  // the vector declared above.
  std::vector<std::string> suggested_strategies_to_reduce_waste = report.SuggestWasteReductionStrategies();
  report_json["suggested_strategies_to_reduce_waste_"] =
      suggested_strategies_to_reduce_waste;

  double total_cost_of_wastage = -9999.0;
  // TODO 6: Call the member function of FoodWastageReport class that returns
  // the total cost of wastage as a double. Store the result in the double
  // declared.
  double total_cost_of_wastage = report.TotalCostOfFoodWasted();
  report_json["total_cost_of_food_wasted_"] = total_cost_of_wastage;

  return report_json;
}

// Util function to convert a crow query string into a FoodWastageRecord class
// object.
FoodWastageRecord QueryStringToFoodWastageRecord(
    const crow::query_string &query_string) {
  FoodWastageRecord record;

  // TODO 1. Get the date from the query_string using query_string.get("date"),
  // and set it in the `record` object using the setter in FoodWastageRecord
  // class.
  std::string date = query_string.get("date");
  record.SetDate(date);

  // TODO 2. Get the meal from the query_string using query_string.get("meal"),
  // and set it in the `record` object using the setter in FoodWastageRecord
  // class.
  std::string meal = query_string.get("meal");
  record.SetMeal(meal);

  // TODO 3. Get the food name from the query_string using
  // query_string.get("food_name"), and set it in the `record` object using the
  // setter in FoodWastageRecord class.
  std::string food_name = query_string.get("food_name");
  record.SetMeal(food_name);

  // TODO 4. Get the quantity from the query_string using
  // std::stod(query_string.get("qty_in_oz")), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  double quantity = std::stod(query_string.get("qty_in_oz"));
  record.SetQuantityInOz(quantity);

  // TODO 5. Get the wastage reason from the query_string using
  // query_string.get("wastage_reason"), and set it in the `record` object using
  // the setter in FoodWastageRecord class.
  std::string wastage_reason = query_string.get("wastage_reason");
  record.SetWastageReason(wastage_reason);

  // TODO 6. Get the disposal mechanism from the query_string using
  // query_string.get("disposal_mechanism"), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  std::string disposal_mechanism = query_string.get("disposal_mechanism");
  record.SetDisposalMechanism(disposal_mechanism);

  // TODO 7. Get the cost from the query_string using
  // std::stod(query_string.get("cost")), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  double cost = std::stod(query_string.get("cost"));
  record.SetCost(cost);

  return record;
}

1 #include "food_wastage_tracker_backend.h"
HN
2
3
#include <filesystem>
4
5
#include "food_wastage_record.h"
6 #include "food_wastage_report.h"
7 #include "server_utils/rapidjson/document.h"
8 #include "server_utils/rapidjson/prettywriter.h"
9 #include "server_utils/rapidjson/rapidjson.h"
10 #include "server_utils/rapidjson/stringbuffer.h" // wrapper of C stream for prettywriter as output
#include "server_utils/rapidjson/writer.h"
11
// rapidjson's DOM-style API
// for stringify JSON
Transcribed Image Text:1 #include "food_wastage_tracker_backend.h" HN 2 3 #include <filesystem> 4 5 #include "food_wastage_record.h" 6 #include "food_wastage_report.h" 7 #include "server_utils/rapidjson/document.h" 8 #include "server_utils/rapidjson/prettywriter.h" 9 #include "server_utils/rapidjson/rapidjson.h" 10 #include "server_utils/rapidjson/stringbuffer.h" // wrapper of C stream for prettywriter as output #include "server_utils/rapidjson/writer.h" 11 // rapidjson's DOM-style API // for stringify JSON
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L