Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions Refactoring/Output.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Refactoring
{
public static class Output
{
internal static void WelcomeMessage()
{
Console.WriteLine("Welcome to TUSC");
Console.WriteLine("---------------");
}

internal static string PromptForUserName()
{
Console.WriteLine();
Console.WriteLine("Enter Username:");
return Console.ReadLine();
}

internal static void InvalidPasswordMessage()
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine("You entered an invalid password.");
Console.ResetColor();
}

internal static void InvalidUserMessage()
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine("You entered an invalid user.");
Console.ResetColor();
}

internal static void PromptForExitKey()
{
Console.WriteLine();
Console.WriteLine("Press Enter key to exit");
Console.ReadLine();
}

internal static string PromptForPassword()
{
Console.WriteLine("Enter Password:");
return Console.ReadLine();
}

internal static void SuccessfulLoginMessage(string name)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine();
Console.WriteLine("Login successful! Welcome " + name + "!");
Console.ResetColor();
}

internal static void RemainingBalanceMessage(double balance)
{
Console.WriteLine();
Console.WriteLine("Your balance is " + balance.ToString("C"));
}

internal static string PromptForPurchaseQuantity()
{
Console.WriteLine("Enter amount to purchase:");
return Console.ReadLine();
}

internal static void LowBalanceMessage()
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine("You do not have enough money to buy that.");
Console.ResetColor();
}

internal static void OutOfStockMessage(string name)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine("Sorry, " + name + " is out of stock");
Console.ResetColor();
}

internal static void PurchaseCancelledMessage()
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine();
Console.WriteLine("Purchase cancelled");
Console.ResetColor();
}

internal static void PurchaseCompleteMessage(int quantity, string name, double balance)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("You bought " + quantity + " " + name);
Console.WriteLine("Your new balance is " + balance.ToString("C"));
Console.ResetColor();
}

internal static void PuchaseIntentMessage(string name, double balance)
{
Console.WriteLine();
Console.WriteLine("You want to buy: " + name);
Console.WriteLine("Your balance is " + balance.ToString("C"));
}
}
}
2 changes: 1 addition & 1 deletion Refactoring/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class Product
[JsonProperty("Price")]
public double Price;
[JsonProperty("Quantity")]
public int Qty;
public int Quantity;
}
}
21 changes: 21 additions & 0 deletions Refactoring/Refactoring.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.core">
<HintPath>..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.core.interfaces">
<HintPath>..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.util">
<HintPath>..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\nunit.util.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.VisualStudio.TestAdapter">
<HintPath>..\packages\NUnitTestAdapter.WithFramework.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -45,11 +64,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Output.cs" />
<Compile Include="Product.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tusc.cs" />
<Compile Include="User.cs" />
<Compile Include="Validation.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
Loading