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
25 changes: 25 additions & 0 deletions PME_ATM/PME_ATM.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PME_ATM", "PME_ATM\PME_ATM.csproj", "{895F99AC-6CEB-4DE0-8A94-EB4A8AE5330A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{895F99AC-6CEB-4DE0-8A94-EB4A8AE5330A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{895F99AC-6CEB-4DE0-8A94-EB4A8AE5330A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{895F99AC-6CEB-4DE0-8A94-EB4A8AE5330A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{895F99AC-6CEB-4DE0-8A94-EB4A8AE5330A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {35E4CC03-686D-4B6A-870C-A648F28CFD34}
EndGlobalSection
EndGlobal
141 changes: 141 additions & 0 deletions PME_ATM/PME_ATM/Models.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace PME_ATM
{
public class Models
{
public static String cur = "NG ";
public static double latestAccount_bal = 5000;
//Making an interface window...lol
public static void showMenu1()
{
Console.WriteLine("|<<<<<---#################--->>>>>>|");
Console.WriteLine("| | ");
Console.WriteLine("| PME Micro Finance Bank ATM |");
Console.WriteLine("| |");
Console.WriteLine("| 1. Insert Your ATM Card |");
Console.WriteLine("| 2. Exist |");
Console.WriteLine("| |");
Console.WriteLine("----------#############-------------");
Console.Write("Please Enter your option ");
}

public static void showMenu2()
{
Console.WriteLine("|<<<<<---#################--->>>>>>|");
Console.WriteLine("| | ");
Console.WriteLine("| PME Micro Finance Bank ATM |");
Console.WriteLine("| |");
Console.WriteLine("| 1. Check balance |");
Console.WriteLine("| 2. Make Deposit |");
Console.WriteLine("| 3. Withdraw Cash |");
Console.WriteLine("| 4. Logout |");
Console.WriteLine("| |");
Console.WriteLine("---------#############--------------");
Console.Write("Please Enter your option ");
}


//Logic from user entries
public static void mainOperation()
{

string menu0 = "";
int menu1 = 0;
int menu2 = 0;
int cardNo = 0;
int pin = 0;
int tries = 0;
int maxTries = 3;

//DateTime xDate = DateTime.Now;

do
{
showMenu1();
menu0 = Console.ReadLine();
if (!Transaction.validateInput(menu0))
{
Console.WriteLine("Invalid Option Entered.");
}
else
{
menu1 = Convert.ToInt32(menu0);
switch (menu1)
{
case 1:
Console.WriteLine("");
Console.WriteLine("Enter ATM Card Number: ");
cardNo = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter 6 Digit PIN: ");
pin = Convert.ToInt32(Console.ReadLine());


if (Validation.checkCardNoPassword(cardNo, pin))
{

do
{

showMenu2();
menu0 = Console.ReadLine();
if (!Transaction.validateInput(menu0))
{
Console.WriteLine("Invalid Option Entered. ");
}
else
{
menu2 = Convert.ToInt32(menu0);
switch (menu2)
{
case 1:
Transaction.printNewBalance(latestAccount_bal);
break;
case 2:
Transaction.deposit();
break;
case 3:
Transaction.Withdraw();
break;
case 4:
Console.WriteLine("You have successfully logout. ");
break;
default:
Console.WriteLine("Invalid Option Entered. ");
break;
}
}
}
while (menu2 != 4);
}
else
{
tries++;

if (tries >= maxTries)
{
Console.WriteLine("Account locked. Please go to the nearest PME Microfinance Bank to rest your PIN.");
Console.WriteLine("Thank you for using PME Microfinance");
System.Environment.Exit(1);
}

Console.WriteLine("Invalid PIN.");
}

break;

case 2:
break;
default:
Console.WriteLine("Invalid Option Entered");
break;
}
}
}
while (menu1 != 2);
Console.WriteLine("Thank you for using PME Microfinance Bank");
}
}
}
8 changes: 8 additions & 0 deletions PME_ATM/PME_ATM/PME_ATM.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>
28 changes: 28 additions & 0 deletions PME_ATM/PME_ATM/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using static PME_ATM.Program;


namespace PME_ATM
{
class Program
{
//Getting and assigning a value the following variables
public static String cur = "NG ";
public static double latestAccount_bal = 5000;
public int cardNo { get; set; }
public int pwd { get; set; }
public string Name { get; set; }

static void Main(string[] args)
{
Models.mainOperation();
}



}


}
92 changes: 92 additions & 0 deletions PME_ATM/PME_ATM/Transaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Text;



namespace PME_ATM
{
public class Transaction
{
private static readonly string cur;

//Method to print avaliable balance
public static void printNewBalance(double newBalance)
{
Console.WriteLine("Balance is: NG " + newBalance.ToString("N"));
Console.WriteLine();
}

//Method to validate user menu selection
public static bool validateInput(string input)
{
bool passValidation = false;
int myInt = 0;
if (!string.IsNullOrWhiteSpace(input))
{
if (int.TryParse(input, out myInt))
passValidation = true;
}
return passValidation;

}

//Method to handle deposit
public static void deposit()
{
double deposit_amt = 0;
Console.Write("Enter your deposit amount: " + cur);
deposit_amt = Convert.ToDouble(Console.ReadLine());

if (deposit_amt > 0)
{
Program.latestAccount_bal = Program.latestAccount_bal + deposit_amt;

Console.WriteLine("You have successfully deposited " + cur + deposit_amt);
printNewBalance(Program.latestAccount_bal);
}
else
{
Console.WriteLine("Invalid deposit amount. Try again");
}
}

//Method to withdraw
public static void Withdraw()
{
double withdraw_amt = 0;
double minimum_kept_amt = 20;

Console.Write("Enter your withdraw amount: " + cur);
withdraw_amt = Convert.ToDouble(Console.ReadLine());

if (withdraw_amt > 0)
{
if (withdraw_amt > Program.latestAccount_bal)
{
Console.WriteLine("Withdrawal failed. You do not have enough fund to withdraw " + cur + withdraw_amt);
}
else if ((Program.latestAccount_bal - withdraw_amt) < minimum_kept_amt)
{
Console.WriteLine("Withdrawal failed. Your account needs to have minimum " + cur + minimum_kept_amt);
}
else
{
Program.latestAccount_bal = Program.latestAccount_bal - withdraw_amt;
Console.WriteLine("Please collect your money. You have successfully withdraw " + cur + withdraw_amt);
Console.WriteLine("Please collect your receipt");
printNewBalance(Program.latestAccount_bal);
}
}
else
{
Console.WriteLine("Invalid withdraw amoun. Try again. (above zero)" + cur);
}
}

internal static void printNewBalance()
{
throw new NotImplementedException();
}
}
}
Loading