Background

Sanele was invited to Lindiwe’s birthday party.
He would have attended anyway since she is a good friend of his. But when he saw the party
would be at her parents’ house and the instruction was to “come hungry,” he was intrigued.
So, he dutifully skipped lunch the day of the party.
As he walked up to the house, the
smell of barbecue started getting
stronger. He was still standing with
his eyes closed and a silly grin on his
face, inhaling as deeply as he could
when she opened the door.
Her melodious laugh brought him
suddenly back to reality.
After an embarrassing moment, he
remembered to wish her a happy
birthday.
It turns out Lindiwe’s parents have
some excellent skills when it comes to cooking. And some secret family recipes, too, it is said.
Sanele was glad that he followed the instruction to come hungry! Chicken, beef, and a leg of lamb
were on the braai, all cooked to perfection. And don’t forget about the roasted mielies.
There was a big pot of pap with a very flavourful chakalaka sauce next to it.
There were salads, roast vegetables, and sweet potatoes. And freshly baked bread straight from
the oven. Sanele was in heaven.
Just when he thought the day couldn’t get any better, it was time for dessert. There was malva
pudding with custard and chocolate pudding with chocolate ice cream. When Lindiwe’s dad
spotted Sanele stuck choosing between the two, he casually suggested, “Why not have both?”
That day, Sanele decided he needed to learn how to cook fantastic food like that.
If a lawyer and a doctor can do this in their free time, so can he.
In this portfolio of evidence, you will develop a recipe app to start him on his journey.

In the first part, you will create a command-line application that allows the user to enter and
store the ingredients and steps for one recipe. In the second part, you will extend it to support
multiple recipes and include nutritional information. In the final submission, you will change the
user interface to a more user-friendly graphical one.

Part 1 — Object-Oriented Programming (Marks: 100)
Learning Units 1 and 2
At the end of this specific part, students should be able to:
 Write a console programme that requires user input.
 Apply string manipulation to solve a programming problem.
 Use automatic properties to solve a programming problem.

Using C# and Visual Studio, design and implement a standalone command line application that
fulfils the following requirements:
1. The user shall be able to enter the details for a single recipe:
a. The number of ingredients.
b. For each ingredient: the name, quantity, and unit of measurement. For example, one
tablespoon of sugar.
c. The number of steps.
d. For each step: a description of what the user should do.
2. The software shall display the full recipe, including the ingredients and steps, in a neat
format to the user.
3. The user shall be able to request that the recipe is scaled by a factor of 0.5 (half), 2
(double), or 3 (triple). All the ingredient quantities shall be changed accordingly when the
recipe is displayed. For example, one tablespoon of sugar will become two tablespoons of
sugar if the factor is 2.
4. The user can request that the quantities be reset to the original values.
5. The user shall be able to clear all the data to enter a new recipe.
6. The software shall not persist the user data between runs. The data shall only be stored in
memory while the software is running.
Non-functional requirements:
1. You are required to use internationally acceptable coding standards. Include
comprehensive comments explaining variable names, methods, and the logic of
programming code.
2. You are required to use classes.
3. Store the ingredients and steps in arrays.

4. Ensure error handling for invalid input from the user.

Sample code for the Recipe class:

```c#
using System;

class Recipe
{
public string[] Ingredients { get; set; }
public string[] Steps { get; set; }

public Recipe()
{
Ingredients = new string[0];
Steps = new string[0];
}

public void AddIngredient(string ingredient)
{
Array.Resize(ref Ingredients, Ingredients.Length + 1);
Ingredients[Ingredients.Length - 1] = ingredient;
}

public void AddStep(string step)
{
Array.Resize(ref Steps, Steps.Length + 1);
Steps[Steps.Length - 1] = step;
}

public void ClearRecipe()
{
Ingredients = new string[0];
Steps = new string[0];
}
}
```

Sample code for the command-line application:

```c#
using System;

class Program
{
static void Main()
{
Recipe recipe = new Recipe();

Console.WriteLine("Enter the number of ingredients:");
int numIngredients = int.Parse(Console.ReadLine());

for (int i = 0; i < numIngredients; i++)
{
Console.WriteLine("Enter ingredient name:");
string ingredientName = Console.ReadLine();
Console.WriteLine("Enter quantity:");
string quantity = Console.ReadLine();
Console.WriteLine("Enter unit of measurement:");
string unit = Console.ReadLine();

string ingredient = $"{quantity} {unit} of {ingredientName}";
recipe.AddIngredient(ingredient);
}

Console.WriteLine("Enter the number of steps:");
int numSteps = int.Parse(Console.ReadLine());

for (int i = 0; i < numSteps; i++)
{
Console.WriteLine($"Enter step {i + 1}:");
string step = Console.ReadLine();
recipe.AddStep(step);
}

// Display the recipe
Console.WriteLine("Recipe:");
foreach (string ingredient in recipe.Ingredients)
{
Console.WriteLine(ingredient);
}

foreach (string step in recipe.Steps)
{
Console.WriteLine(step);
}
}
}
```

This code snippet demonstrates a basic command-line application that allows the user to input ingredients and steps for a recipe. The Recipe class is used to store the recipe data, and the Program class handles user input and output. The user can enter the details of the recipe, and it will be displayed in a neat format. The next steps would be to implement the scaling and resetting functionality as well as error handling for invalid input.