Hello, I’m working on this task:
Users of your glass-refilling program were quite happy, but their feedback indicates that they dislike the raw math figures. Using your previous program as a basis, instead of printing a message to the screen when the user inputs print, draw a glass using ASCII art. Represent the glass as a vertical bar (see example) and fill it with ‘#’ symbols proportional to how much liquid it has. The height of the glass should be 4 symbols, the width 4 symbols, and all empty space inside the glass should be filled with spaces.
Example 1:
>drink 37
| |
|##|
|##|
|##|
>stop
Example 2:
>drink 145
>print
|##|
|##|
|##|
|##|
>stop
Here is my code:
namespace ClassAndObjectAndAsciiArt
{
class Glass
{
public int LiquidLevel;
public void Drink(int milliliters)
{
LiquidLevel = LiquidLevel - milliliters;
}
public void Refill()
{
LiquidLevel = 200;
}
}
public class LackOfVisualization
{
public static void Main()
{
var glass = new Glass{
LiquidLevel = 200;
}
var command = string.Empty;
while (command != "stop")
{
command = Console.ReadLine();
var splitCommand = command.Split(' ');
switch (splitCommand[0])
{
case "stop":
return;
case "print":
if (glass.LiquidLevel >= 200){
Console.WriteLine("|##|");
Console.WriteLine("|##|");
Console.WriteLine("|##|");
Console.WriteLine("|##|");
}
else if (glass.LiquidLevel < 200 && glass.LiquidLevel >= 150){
Console.WriteLine("| |");
Console.WriteLine("|##|");
Console.WriteLine("|##|");
Console.WriteLine("|##|");
}
else if (glass.LiquidLevel < 150 && glass.LiquidLevel >= 100){
Console.WriteLine("| |");
Console.WriteLine("| |");
Console.WriteLine("|##|");
Console.WriteLine("|##|");
}
break;
case "drink":
glass.Drink(int.Parse(splitCommand[1]));
if (glass.LiquidLevel < 100)
{
glass.Refill();
}
break;
}
}
}
}
}
Can anyone please help me to solve it? Getting so many error lines dont know where to begin…