OOP Project
OOP Project
CODE:
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <windows.h> // for Sleep function
using namespace std;
public:
Authentication(T uname, T pass) : username(uname), password(pass) {}
public:
Bill() : Item(""), Rate(0), Quantity(0) {}
int getRate()
{
return Rate;
}
int getQuant()
{
return Quantity;
}
};
if (choice == 1)
{
system("cls");
T item;
int rate, quant;
void printBill()
{
system("cls");
int count = 0;
bool close = false;
while (!close)
{
system("cls");
int choice;
cout << "\t1.Add Bill." << endl;
cout << "\t2.Close Session." << endl;
cout << "\tEnter Choice: ";
cin >> choice;
if (choice == 1)
{
string item;
int quant;
cout << "\tEnter Item: ";
cin >> item;
cout << "\tEnter Quantity: ";
cin >> quant;
ifstream in("Bill.txt");
ofstream out("BillTemp.txt");
string line;
bool found = false;
if (item == itemName)
{
found = true;
if (quant <= itemQuant)
{
int amount = itemRate * quant;
cout << "\t Item | Rate | Quantity | Amount"
<< endl;
cout << "\t" << itemName << "\t " <<
itemRate << "\t " << quant << "\t " << amount << endl;
int newQuant = itemQuant - quant;
itemQuant = newQuant;
count += amount;
if (auth.authenticate(username, password))
{
Bill<string> b;
if (val == 1)
{
system("cls");
addItem(b);
Sleep(3000);
}
else if (val == 2)
{
printBill();
}
else if (val == 3)
{
viewBillHistory(); // Call the function to view bill history
}
else if (val == 4)
{
system("cls");
exit = true;
cout << "\tGood Luck!" << endl;
Sleep(3000);
}
}
}
else
{
cout << "Authentication failed. Exiting program." << endl;
Sleep(3000);
}
system("pause");
return 0;
}