Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Friday, 6 July 2018

Library Management System in Python Complete Program

# CANSOLE BASED PROJECT
import os;
import time;
#************************************ WELCOME SCREEN **********************************
def welcome():
    os.system("cls");
    os.system("color 1A");
    time.sleep(0.3);
    print(" ".rjust(78,"="))
    time.sleep(1/4);
    print("                     WELCOME TO CETPA LIBRARY MANAGEMET SYSTEM")
    time.sleep(1/4);
    print("                                INDRA NAGAR LUCKNOW UP")
    time.sleep(1/4);
    print("                        Console Based PROJECT BY MOHD MUJTABA(Batch-13June)")
    time.sleep(1/4);
    print(" ".rjust(78,"="))
    time.sleep(1/4);
    menu();
#******************************** MAIN MENU *************************************             
def menu():
    print(" ".rjust(78,"="))
    print("                     LOGIN MANAGEMENT SYSTEM<AUTHORISED>")
    print(" ".rjust(78,"="))
    print("""   1. STUDENT
   2. ADMIN/STAFF""");
    choice=int(input("     Enter Your Choice:"))
    if(choice!=1 and choice!=2):
        print("Wrong Choice Enter Again:!");
        os.system("cls");
        menu();
    elif(choice==1):
        studentMenu();
    elif(choice==2):
        adminMenu();
#************************** STUDENT MENU *******************************
def studentMenu():
    os.system("cls");
    os.system("color 2E");
    print(" ".rjust(78,"="))
    print("                     STUDENT MENU WINDOW<AUTHORISED>")
    print(" ".rjust(78,"="))
    print("""    1. EXISTING USER(LOGIN)
    2. NEW USER(SIGN UP)
    3. DELETE USER
    4. LOG OFF
    5. EXIT.""");
    choice=input("        Enter Your Choice:")
    if(choice=='1'):
        studLogin();
         
    elif(choice=='2'):
        studRegister();
    elif(choice=='3'):
        studdelete();
    elif(choice=='4'):
        welcome();
    elif(choice=='5'):
        exit();
    else:
        print("Wrong Choice Try Again:");
        time.sleep(1);
        studentMenu();
#*********************** STUDENT REGISTRATION ************************
def studRegister():
        os.system("cls");
        os.system("color 3F");
        check=1;
        print(" ".rjust(78,"="))
        print("                     NEW STUDENT REGISTRATION WINDOW")
        print(" ".rjust(78,"="))
        f=open('D:/Python Lucknow/studreg.txt'); 

        id=input("Enter STUDENT ID(MUST BE UNIQUE):");
        while True:
                l=f.readline().split(",");
                print(l);
                if(id==l[0]):
                        print("Record Already Exist! Kindly Proceed To Login:");
                        time.sleep(2);
                        f.close();
                        studentMenu();
                if(l==['']):
                        break;
        name=input("Choose Your Name(MIN 4 CHARACTER):");
        username=name[:4]+str(id);
        while(check):
                pwd=input("Enter New Password:")
                cnfpwd=input("Re-Enter Password:");
                if(pwd!=cnfpwd):
                        print("Password Do not Match! Kindly Enter Again!");
                        check=1;
                else:
                        break;
        filecontent=str(id)+","+name+","+username+","+pwd+"\n";
        open('D:/Python Lucknow/studreg.txt',"a").write(filecontent);
        print("Acocunt Created Successfully Wait(2 Second:)");
        time.sleep(2);
        f.close();
        studentMenu();
    
#*********************** STUDENT LOGIN ******************************
def studLogin():
        os.system("cls");
        os.system("color 4E");
        print(" ".rjust(78,"="))
        print("                     STUDENT LOGIN WINDOW<AUTHORISED>")
        print(" ".rjust(78,"="))
        user=input("Enter UserName:");
        pwd=input("Enter Password:");
        f=open('D:/Python Lucknow/studreg.txt');
        l=f.readlines()
        m=0
        for i in l:
                print(i.split(','))
                if (user==i.split(',')[2] and pwd==i.split(',')[3].split()[-1]):
                        print("Login SuccessFul: Wait Redirecting.....");
                        time.sleep(1/4);
                        f.close();
                        studMainMenu(i);
                        break;
        if m==0:
                print("Invalid UserName Or Password! Kindly Enter Again!:");
                time.sleep(1);
                f.close();
                studLogin();
        f.close();
            
#******************** STUDENT DELETE USER **********************************
def studdelete():
        os.system("cls");
        os.system("color 5B");
        userid=input("Enter Your UserName(99 to Exit):");
        f=open("D:/Python Lucknow/studreg.txt");
        f1=open("D:/Python Lucknow/studreg1.txt","w");
        while True:
                if(userid==str(99)):
                        studentMenu();
                l=f.readline().split(",")
                print(l);
                if(l==['']):
                        print("User Id Does Not Exist:\nKindly Enter Again");
                        f.close();
                        f1.close();
                        studdelete();
                if(l[2]==userid):
                        f1.write(f.read());
                        f1.close();
                        f.close();
                        os.remove("D:/Python Lucknow/studreg.txt");
                        os.rename("D:/Python Lucknow/studreg1.txt","D:/Python Lucknow/studreg.txt");
                        print("Record Deleted!.....Wait(2 Sec)");
                        time.sleep(3/2);
                        studentMenu();
                filecontent=",".join(l);
                f1.write(filecontent);
#*************************STUDENT <MAIN MENU>*********************
def studMainMenu(l):
    os.system("cls");
    os.system("color 4A");
    print(" ".rjust(78,"="))
    time.sleep(1/3);
    print(" ".rjust(78,"="))
    print("                               STUDENT MAIN MENU<AUTHORISED>")
    time.sleep(1/2);
    print(" ".rjust(78,"="))
    print("""\n\n   1. ISSUE BOOK
   2. RETURN BOOK
   3. VIEW ISSUED BOOK
   4. LOG OFF.
   5. EXIT """);
    ch=0;
    while(ch<1 or ch>5):
        ch=int(input("Enter Your Choice....."));
        if(ch==1):
            issueBook(l);
        elif(ch==2):
            returnBook(l);
        elif(ch==3):
            viewIssuedBook(l);
        elif(ch==4):
            studentMenu();
        elif(ch==5):
            exit();
        else:
            print("Wrong Choice!! Enter Again...");
#********************** ISSUE BOOK(STUDENT) **********************
def issueBook(l):
    os.system("cls");
    os.system("color 5B");
    
    id=l.split(",")[0];
    name=l.split(",")[1];
    print("Student Name:",name,"  Id:",id);
    f=open("D:/Python Lucknow/addbook.txt","r");
    f1=open("D:/Python Lucknow/issuedbook.txt","a");
    f2=open("D:/Python Lucknow/addbook1.txt","w");
    bname=input("Enter BOOK NAME:");
    check=0;
    while True:
        rl=f.readline().split(",");
        if(rl==['']):
            print("No Book's Found:Redirecting...");
            time.sleep(1);
            f.close();
            f1.close();
            f2.close();
            studMainMenu(l);
            break;
        elif(bname==rl[1]):
            file=id+","+name+","+bname+"\n";
            f1.write(file);
            f.close();
            f1.close();
            f2.close();
            check=1;
            break;
    if(check==1):
        f=open("D:/Python Lucknow/addbook.txt","r").readlines();
        for i in f:
            p=i.split(",");
            if(p[1]==bname):
                p[3]=str(int(p[3])+1);
                open("D:/Python Lucknow/addbook1.txt","a").write(",".join(p));
                check=2;
            else:
                open("D:/Python Lucknow/addbook1.txt","a").write(",".join(p));
    if(check==2):
        f2.close();
        os.remove("D:/Python Lucknow/addbook.txt");
        os.rename("D:/Python Lucknow/addbook1.txt","D:/Python Lucknow/addbook.txt");
        print("Book Issued....Redirecting.....");
        time.sleep(1);
        studMainMenu(l);
#***************************** RETURN BOOK<STUDENT> ******************************
def returnBook(l):
    os.system("cls");
    os.system("color 9E");
    check=0;
    f=open("D:/Python Lucknow/issuedbook.txt");
    line=l.split(",");
    count=0;
    while True:
        rl=f.readline().split(",");
        if(rl==['']):
            if(count==0):
                print("No Book is Issued...Redirecting....");
                time.sleep(1.3);
                f.close();
                studMainMenu(l);
            else:
                f.close();
                break;
        elif(line[1]==rl[1]):
            print(rl);
            count=1;
      
    name=input("Enter BOOK NAME:");
    #f=open("D:/Python Lucknow/addbook1.txt","w");
    f1=open("D:/Python Lucknow/issuedbook1.txt","w");
    f2=open("D:/Python Lucknow/addbook1.txt","w");
    f3=open("D:/Python Lucknow/issuedbook.txt");
    
    while True:
        if(name==str(99)):
            studentMainMenu(l);
        l3=f3.readline().split(",")
        print(l3);
        if(l3==['']):
            print("No Book Found! Redirecting.....");
            time.sleep(1);
            f1.close();
            f2.close();
            f3.close();
            os.remove("D:/Python Lucknow/issuedbook1.txt");
            os.remove("D:/Python Lucknow/addbook1.txt");
            studMainMenu(l);
        elif(l3[2].split("\n")[0]==name and line[1]==l3[1]):
            f1.write(f3.read());
            f1.close();
            f3.close();
            f2.close();
            check=1;
            os.remove("D:/Python Lucknow/issuedbook.txt");
            os.rename("D:/Python Lucknow/issuedbook1.txt","D:/Python Lucknow/issuedbook.txt");
            break;
        else:
            filecontent=",".join(l3);
            f1.write(filecontent);

    if(check==1):
        f=open("D:/Python Lucknow/addbook.txt","r").readlines();
        for i in f:
            p=i.split(",");
            if(p[1]==name):
                p[3]=str(int(p[3])-1);
                open("D:/Python Lucknow/addbook1.txt","a").write(",".join(p));
                check=2;
            else:
                open("D:/Python Lucknow/addbook1.txt","a").write(",".join(p));
    if(check==2):
        f2.close();
        os.remove("D:/Python Lucknow/addbook.txt");
        os.rename("D:/Python Lucknow/addbook1.txt","D:/Python Lucknow/addbook.txt");
        print("Record Deleted!.....Wait(2 Sec)");
        time.sleep(3/2);
        studMainMenu(l);
#******************************** VIEW ISSUED BOOK<STUDENT>*********************
def viewIssuedBook(q):
    p=q.split(",");
    os.system("cls");
    os.system("color 6E");
    f=open("D:/Python Lucknow/issuedbook.txt");
    print("UID\t\tNAME\t\t\BOOK NAME");
    while(True):
        l=f.readline().split(",");
        if(l==['']):
            f.close();
            ch=input("Enter (Y/y) To Go Back:");
            if(ch=='y' or ch=='Y'):
                studMainMenu(q);
                break;
            else:
                exit();
        elif(p[1]==l[1]):
            print(l[0],'\t\t',l[1],'\t\t',l[2]);
    
#********************* ADMIN MENU *******************************
def adminMenu():
    os.system("cls");
    os.system("color 9F");
    
    print(" ".rjust(78,"="))
    print("                     ADMINSTRATIVE MENU WINDOW<AUTHORISED>")
    print(" ".rjust(78,"="))
    print("""    1. EXISTING USER(LOGIN)
    2. NEW USER(SIGN UP)
    3. DELETE USER
    4. LOG OFF
    5. EXIT.""");
    choice=input("        Enter Your Choice:")
    if(choice=='1'):
        adminLogin();
    elif(choice=='2'):
        adminRegister();
    elif(choice=='3'):
        admindelete();
    elif(choice=='4'):
        welcome();
    elif(choice=='5'):
        exit();
        
    else:
        print("Wrong Choice Try Again:");
        time.sleep(1);
        adminMenu();
#*********************** ADMIN REGISTRATION ************************
def adminRegister():
    os.system("cls");
    os.system("color 4F");
    
    check=1;
    print(" ".rjust(78,"="))
    print("                     NEW ADMIN REGISTRATION WINDOW")
    print(" ".rjust(78,"="))
    f=open('D:/Python Lucknow/admin.txt'); 

    id=input("Enter ADMIN ID(MUST BE UNIQUE):");
    while True:
        l=f.readline().split(",");
        print(l);
        if(id==l[0]):
            print("Record Already Exist! Kindly Proceed To Login:");
            time.sleep(2);
            f.close();
            adminMenu();
        if(l==['']):
                break;
    name=input("Enter ADMIN Name(MIN 4 CHARACTER):");
    username=name[:4]+str(id);
    while(check):
        pwd=input("Enter New Password:")
        cnfpwd=input("Re-Enter Password:");
        if(pwd!=cnfpwd):
            print("Password Do not Match! Kindly Enter Again!");
            check=1;
        else:
            break;
    filecontent=str(id)+","+name+","+username+","+pwd+"\n";
    print(filecontent);
    open('D:/Python Lucknow/admin.txt',"a").write(filecontent);
    print("Acocunt Created Successfully Wait(2 Second:)");
    time.sleep(2);
    f.close();
    adminMenu();
    
#*********************** ADMIN LOGIN ******************************
def adminLogin():
    os.system("cls");
    os.system("color 8E");
    print(" ".rjust(78,"="))
    print("                     ADMIN LOGIN WINDOW<AUTHORISED>");
    print(" ".rjust(78,"="))
    user=input("Enter UserName(99 for Main Menu):");
    pwd=input("Enter Password:");
    f=open('D:/Python Lucknow/admin.txt');
    l=f.readlines()
    m=0
    
    for i in l:
        if(user=='99'):
            welcome();
            break;
        print(i.split(','))
        if (user==i.split(',')[2] and pwd==i.split(',')[3].split()[-1]):
                print("Login SuccessFul:");
                m=1;
                f.close();
                adminMainMenu(i);     
    if m==0:
        print("Invalid UserName Or Password:Redirecting...");
        time.sleep(1/2);
        f.close();
        adminLogin();
         
#******************** ADMIN DELETE USER ********************************
def admindelete():
    print(" ".rjust(78,"="))
    print("                    DELETE USER WINDOW<AUTHORISED>")
    print(" ".rjust(78,"="))
    userid=input("Enter Your UserName(99 to Exit):");
    f=open("D:/Python Lucknow/admin.txt");
    f1=open("D:/Python Lucknow/admin1.txt","w");
    while True:
        if(userid==str(99)):
            adminMenu();
        l=f.readline().split(",")
        print(l);
        if(l==['']):
            print("User Id Does Not Exist:\nKindly Enter Again");
            f.close();
            f1.close();
            admindelete();
        if(l[2]==userid):
            f1.write(f.read());
            f1.close();
            f.close();
            os.remove("D:/Python Lucknow/admin.txt");
            os.rename("D:/Python Lucknow/admin1.txt","D:/Python Lucknow/admin.txt");
            print("Record Deleted!.....Wait(2 Sec)");
            time.sleep(3/2);
            adminMenu();
    filecontent=",".join(l);
    f1.write(filecontent);
# ************************* ADMIN MAIN MENU *****************************
def adminMainMenu(l):
    os.system("cls");
    os.system("color 9F");
    time.sleep(1/5);
    print(" ".rjust(78,"="))
    time.sleep(1/5);
    print("                     WELCOME TO CETPA LIBRARY MANAGEMET SYSTEM")
    time.sleep(1/5);
    print("                                INDRA NAGAR LUCKNOW UP")
    time.sleep(1/5);
    print("                        Console Based PROJECT BY MOHD MUJTABA")
    time.sleep(1/5);
    print(" ".rjust(78,"="))
    time.sleep(1/4);
    print(" ".rjust(78,"="))
    print("                               ADMIN MAIN MENU<AUTHORISED>")
    print(" ".rjust(78,"="))
    print("""\n\n   1. ADD NEW BOOK
   2. Delete BOOK
   3. View BOOKS
   4. Charge Fine
   5. Total Fine Collected
   6. LOG OFF.
   7. EXIT""");
#5. Fine Collected(Student Wise)
    choice=input("Enter Your Choice.......:");
    if(choice=='1'):
        addBook(l);
    elif(choice=='2'):
        delBook(l);
    elif(choice=='3'):
        viewBook(l);
    elif(choice=='4'):
        chargeFine(l);
##    elif(choice==5):
##        totalFineStudentWise(l);
    elif(choice=='5'):
        totalFine(l);
    elif(choice=='6'):
        adminMenu();
    elif(choice=='7'):
        exit();
    else:
        print("Wrong Option Selected! Try again..:");
        time.sleep(3/2);
        adminMainMenu(l);
#************************* ADD BOOK ********************************
def addBook(l):
    os.system("cls");
    os.system("color 4F");
    f=open("D:/Python Lucknow/addbook.txt","a");
    f1=open("D:/Python Lucknow/addbook.txt");

    isbn=input("Enter ISBN Number:");
    while True:
        l=f1.readline().split(",");
        print(l);
        
        if(isbn==l[0]):
            print("Record Already Exist! Redirecting To Main Menu......:");
            time.sleep(1.5);
            f.close();
            f1.close();
            adminMainMenu(l);
            
            
        if(l==['']):
                break;
    name=input("Enter Book Name:");
    author=input("Enter Author Name:");
    quantity=input("Enter Quantity:");
    issued=0;
    file=isbn+","+name+","+quantity+","+str(issued)+","+author+"\n"
    f.write(file);
    print("Record Updated Successfully.......");
    ch=input("Do You Want To Add More....(Y/N):");
    f.close();
    f1.close();
    if(ch=="y" or ch=='Y'):     
        addBook();
    else:
        adminMainMenu(l);
#****************************** VIEW BOOK *******************************
def viewBook(l):
    os.system("cls");
    os.system("color 6E");
    f=open("D:/Python Lucknow/addbook.txt");
    print("ISBN\t\tName\t\t\tQuantity\t\tIssued\t\tAuthor");
    while(True):
        l=f.readline().split(",");
        if(l==['']):
            f.close();
            ch=input("Enter (Y/y) To Go Back:");
            if(ch=='y' or ch=='Y'):
                adminMainMenu(l);
            else:
                exit();
        else:
            print(l[0],'\t\t',l[1],'\t\t',l[2],'\t\t',l[3]+'\t\t'+l[4]);    
# ******************************* DELETE BOOK ****************************
def delBook(l):
    print(" ".rjust(78,"="))
    print("                    DELETE BOOK RECORD<ADMIN>")
    print(" ".rjust(78,"="))
    isbn=input("Enter ISBN Number(99 to Exit):");
    f=open("D:/Python Lucknow/addbook.txt");
    f1=open("D:/Python Lucknow/addbook1.txt","w");
    while True:
        if(isbn==str(99)):
            adminMainMenu(l);
        else:
            l=f.readline().split(",")
            if(l==['']):
                print("Book Does Not Exist:\nKindly Enter Again");
                f.close();
                f1.close();
                delBook();
            if(l[0]==isbn):
                f1.write(f.read());
                f1.close();
                f.close();
                os.remove("D:/Python Lucknow/addbook.txt");
                os.rename("D:/Python Lucknow/addbook1.txt","D:/Python Lucknow/addbook.txt");
                print("Record Deleted!.....Wait(2 Sec)");
                time.sleep(3/2);
                adminMainMenu(l);
            else:
                filecontent=",".join(l);
                f1.write(filecontent);
#****************************** CHARGE FINE**************************
def chargeFine(l):
    os.system("cls");
    print(" ".rjust(78,"="))
    print("                    FINE COLLECTION WINDOW<ADMIN>")
    print(" ".rjust(78,"="))
    p=l.split(",");
    uid=p[0];
    name=p[1];
    print(uid,name);
    studid=input("Enter Student UID:");
    f=open("D:/Python Lucknow/studreg.txt","r").readlines();
    p=[i for i in f if(i.split(",")[0]==studid)]
    if(len(p)==0):
        print("NO UID FOUND! Redirecting.....");
        time.sleep(3/2);
        chargeFine(l);
    else:
        print("Student Name: ",p[0].split(",")[1]);
        studname=p[0].split(",")[1];
        bname=input("Enter Book Name for fine to be Charged:");
        f=open("D:/Python Lucknow/addbook.txt","r").readlines();
        p=[i for i in f if(i.split(",")[1]==bname)]
        if(len(p)==0):
            print("NO BOOK FOUND! Redirecting.....");
            time.sleep(3/2);
            chargeFine(l);
        else:
            fine=input("Enter Fine Amount:");
            file=studid+","+studname+","+bname+","+fine+","+uid+","+name+"\n";
            open("D:/Python Lucknow/fine.txt","a").write(file);
            print("Congrats!",studname,"You Have Been Fined for Rs:",fine);
            print("Please Wait Redirecting......");
            time.sleep(1);
            adminMainMenu(l);
#*******************************TOTAL FINE(STUDENT WISE)*******************
#*******************************TOTAL FINE**********************************
def totalFine(l):
    tot=0;
    f=open("D:/Python Lucknow/fine.txt","r").readlines();
    for i in f:
        tot+=int(i.split(",")[3])
    print("Total Fine Collected Till Now:",tot);
    ch=input("Press (Y/y) To Go Back:");
    if(ch=='y' or ch=="Y"):
        adminMainMenu(l);
    else:
        exit();
#************************** CALLING THE MAIN FUNCTION ****************
welcome();

Sunday, 1 July 2018

Pizza Hut Management System Project in C++

//This Program Is Created By Mohd Mujtaba Section-K1613 Roll No-B47 Reg No-11608125

//*******************************PROGRAM STARTS FROM HERE*********************************************
#include<iostream> // can be remove when using fstream
#include<fstream>
#include<conio.h> // getch()
#include<stdio.h> // gets,puts, 
#include<stdlib.h> // system("cls") system("PAUSE") exit() remove() rename()
#include<string.h> // strcpy strlen strcmp etc..
#include<iomanip>
#include<windows.h>   //Sleep()
#include<bits/stdc++.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // used for goto
COORD CursorPosition; 

void gotoxy(int x,int y)
{
CursorPosition.X=x;
CursorPosition.Y=y;
SetConsoleCursorPosition(console,CursorPosition); 

}

using namespace std;
fstream f1;
fstream f2;
fstream f3;
fstream f4;


int i,temp,found=0,total=0;
char chop='y';
int i_code1;



class menu
{
protected:
float price;
char p_name[20];
public:
int i_code;
void get_menu();
void show_menu();
void delPizzaMenu();
};
class order: public menu
{
protected:
char name[30],add[80];
int bill_no,i_code2;
long long mbno;
public:
void modify();

void get_order();
void show_order();
void gen_bill(int,int);
void search();
void del_rec();

};

class lovely_pizza:public order
{
public:




void home_page()
{

int menuch=1;
bool value=true;
int x=7;
// MENU:



while(value)
{
system("cls");
gotoxy(14,x);
cout<<"->";
system("color 1A");
gotoxy(18,1);
cout<<setw(30)<<"             ==================================================";
gotoxy(18,2);
// Sleep(150);
cout<<setw(30)<<"                      WELCOME TO LOVELY PIZZA PVT. LTD. ";
gotoxy(18,4);
// Sleep(150);
cout<<setw(30)<<"                               PHAGWARA PUNJAB";
gotoxy(18,5);
// Sleep(150);
cout<<setw(30)<<"            ===================================================";
gotoxy(18,6);
// Sleep(100);
gotoxy(18,7);
cout<<"1. NEW ORDER:";
gotoxy(18,8);
cout<<"2. ALL ORDER DETAILS:";
gotoxy(18,9);
cout<<"3. SEARCH ORDER";
gotoxy(18,10);
cout<<"4. Modify ORDER:";
gotoxy(18,11);
cout<<"5. Delete ORDER :";
gotoxy(18,12);
cout<<"6. Enter Pizza Menu Details:";
gotoxy(18,13);
cout<<"7. Show Pizza  MENU:";
gotoxy(18,14);
cout<<"8. Delete Pizza Details:";
gotoxy(18,15);
cout<<"9. Exit (Sign Out):";
gotoxy(18,16);
cout<<"Choose One Option...... :";
system("pause>nul"); // the >nul bit causes it the print no message

if(GetAsyncKeyState(VK_DOWN) && x != 16)
{
gotoxy(14,x);
cout<<"  ";
x++;
cout<<"->";
menuch++;
continue;
}
if(GetAsyncKeyState(VK_UP)&&x!=7)
{
gotoxy(14,x);
cout<<"  ";
x--;
cout<<"->";
menuch--;
continue;
}
if(GetAsyncKeyState(VK_RETURN))
{

switch(menuch)
{
case 1:
system("cls");

get_order();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
case 2:
system("cls");
f2.open("D:/order.txt",ios::in|ios::out|ios::app);
show_order();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
case 3:
search();
cout<<"Press Again Any Key...#BACK #TO #MENU:";
getch();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
case 4:
system("cls");
modify();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
    case 5:
    del_rec();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
     
case 6:

        f1.open("D:\\menu.txt",ios::out|ios::app);
    get_menu();
f1.close();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
case 7:
system("cls");
    f1.open("D:/menu.txt");
    show_menu();
    f1.close();
    getch();
    // goto MENU; // REDIRECTED TO MENU LABEL
    break;
case 8:
delPizzaMenu();
// goto MENU; // REDIRECTED TO MENU LABEL
break;
case 9:
system("cls");

for(i=0;i<50;i++)
{

cout<<"/";
if(i==26)
cout<<"Saving And Exiting.....:";
Sleep(30);
}

exit(42);
value=false;

}
}
}
gotoxy(18,19);
}

}pizza;

void menu::get_menu()
{
system("color 2F");
do
{
system("cls");
cout<<setw(30)<<"Enter All Pizza DETAILS With PRICES:\n\n";
cout<<"Enter Item Code:";
fflush(stdin);
    
cin>>i_code;
cout<<"Pizza Name;";
fflush(stdin);
gets(p_name);
cout<<"Price:";
cin>>price;
f1.write((char*)&pizza,sizeof(pizza));
system("cls");
cout<<"Record Entered.......\n"<<setw(15)<<"Want To Enter Any More (Y/N):";
cin>>chop;

}while(chop=='y'||chop=='Y');
}

void menu::show_menu()
{
system("color 1A");
cout<<"Item_Code"<<setw(18)<<"Name"<<setw(25)<<"Price"<<"\n";
while(f1.read((char*)&pizza,sizeof(pizza)))
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";
}

void order::modify()
{
MODIFY:
found=0;
int mbno1,x;
char cnfModify;
cout<<"Enter Mobile_No:";
cin>>mbno1;
f2.open("D:\\order.txt",ios::in|ios::out|ios::app);
f3.open("D:\\order1.txt",ios::in|ios::out|ios::app);


cout<<"Bill_No:"<<setw(10)<<"Name"<<setw(20)<<"Address"<<setw(20)<<"Mobile No"<<setw(20)<<"Pizza Code"<<"\n";
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(mbno1==mbno)
{
cout<<bill_no<<setw(20)<<name<<setw(20)<<add<<setw(15)<<mbno<<setw(20)<<i_code2<<"\n";
//
//
cout<<"\nWant To Modify This:(Y/y):";
fflush(stdin);
cin>>cnfModify;
fflush(stdin);
if(cnfModify=='y'||cnfModify=='Y')
{
cout<<"\nEnter New Pizza Code:";
cin>>i_code2;

}
f3.write((char*)&pizza,sizeof(pizza));
found=1;
}


}
if(found==0)
{
cout<<"File Not Found!!! ENTER AGAIN::";
system("PAUSE");
f2.close();
    f3.close();
goto MODIFY;
}

f2.close();
f3.close();



f2.open("D:\\order.txt",ios::in|ios::out|ios::app);
f3.open("D:\\order1.txt",ios::in|ios::out|ios::app);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(mbno1==mbno)
continue;
else
f3.write((char*)&pizza,sizeof(pizza));
}
f2.close();
f3.close();
remove("D://order.txt");
rename("D://order1.txt","D://order.txt");

cout<<"\n\n Record Updated!! Press Any Key For MENU";
getch();
}

void order::get_order()
{
    int x,tempBillCount=0;
char ch;
f2.open("D:\\order.txt",ios::out|ios::in|ios::app);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
tempBillCount++;

}
f2.close();
f2.open("D:\\order.txt",ios::out|ios::in|ios::app);
bill_no=tempBillCount+1;
cout<<"Enter Name:";
fflush(stdin);
gets(name);
cout<<"Enter Address:";
fflush(stdin);
gets(add);
cout<<"Enter Mobile Number:";
cin>>mbno;
fflush(stdin);

AGAIN:                   //GOTO STATEMENT

cout<<"Enter Pizza(ITEM) Code:";
fflush(stdin);
cin>>i_code2;  

f2.write((char*)&pizza,sizeof(pizza));    //storing The Data of Only Pizza Menu And That is also of last menu
  cout<<"Do You Want To Enter More:";
cin>>ch;
if(ch=='y'||ch=='Y')
goto AGAIN; // goto to again LABEL
f2.close();
gen_bill(mbno,bill_no);
getch();                 //its just like printing the bill after order;

       
}
void order::show_order()
{
system("Color 5F");
int x;
// f1.open("D:\\menu.txt",ios::in|ios::out|ios::app);
cout<<"Bill_No:"<<setw(10)<<"Name"<<setw(20)<<"Address"<<setw(20)<<"Mobile No"<<setw(20)<<"Pizza Code"<<"\n\n";
while(f2.read((char*)&pizza,sizeof(pizza)))
{
cout<<bill_no<<setw(20)<<name<<setw(20)<<add<<setw(15)<<mbno<<setw(20)<<i_code2<<"\n";
x=i_code2;
fflush(stdin);
//cout<<"\nItem_Code"<<setw(18)<<"Pizza Name"<<setw(25)<<"Price"<<"\n\n";
// cout<<i_code2<<setw(25)<<p_name<<setw(20)<<price<<"\n";


}
getch();

f2.close();

/* while(f1.read((char*)&pizza,sizeof(pizza)));
{
if(x==i_code)
{

cout<<"\nItem_Code"<<setw(18)<<"Pizza Name"<<setw(25)<<"Price"<<"\n\n";
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";
cout<<"\n\n\n\n\n\n\n"<<setw(50)<<"Amount-->RS "<<total;
}
f1.close();


} */

}

void order::gen_bill(int a, int tempBillNo)
{
system("color 1A");
int i_bill;
float total=0;

system("cls");
cout<<setw(80)<<"_______________________________________\n";
cout<<setw(80)<<"|=====================================|\n";
cout<<setw(80)<<"|          LOVELY PIZZA PVT. LTD      |\n";
cout<<setw(80)<<"|                                     |\n";
cout<<setw(80)<<"|       Jalandhar-Phagwara Highway    |\n";
cout<<setw(80)<<"|             Chehru -Punjab          |\n";
cout<<setw(82)<<"|=====================================|\n\n\n";

cout<<"Customer Name:"<<name<<"\t\tBill No:"<<tempBillNo;
cout<<"\nAddress:"<<add;
cout<<"\nContact No:"<<mbno;
//f1.open("D:\\menu.txt",ios::in|ios::out|ios::app);
f2.open("D:\\order.txt",ios::in|ios::out|ios::app);
cout<<"\n===================================================================\n";
cout<<"\n===================================================================\n";
cout<<"\n\nItem_Code"<<setw(18)<<"Pizza Name"<<setw(25)<<"Price"<<"\n\n";
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(a==mbno)
{
i_bill=i_code2;

f1.open("D:\\menu.txt",ios::in|ios::out|ios::app);
while(f1.read((char*)&pizza,sizeof(pizza)))
{
if(i_bill==i_code)
{
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";
total+=price;
break;
}

}
f1.close();
}
    }
    cout<<"\n\n"<<setw(40)<<"TOTAL COST FOR ORDER IS RS:"<<total<<"\n";
    cout<<setw(50)<<"THANK YOU! AND VISIT AGAIN:\n";
//f1.close();
f2.close();
}

void order::search()
{
  system("Color 2F");
 
long b;
  float total=0;

  Back: //goto function to move back and search again.....

  system("cls");
  found=0;
cout<<"Enter Mobile_No To Be Searched: \n"<<setw(10)<<"Enter 99 Any time When You Wish To go Back(MENU): ";
cin>>b;
f2.open("D:\\order.txt",ios::in|ios::out|ios::app);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(b==mbno)
{
cout<<"\n\nCustomer Name:"<<name;
cout<<"\nAddress:"<<add;
cout<<"\nContact No:"<<mbno;
found=1;
break;
}
}
f2.close();
if(found==1)
{
cout<<"\n\nItem_Code"<<setw(18)<<"Pizza Name"<<setw(25)<<"Price"<<"\n\n";
f2.open("D:\\order.txt",ios::in|ios::out|ios::app);
// f2.seekp(0,ios::beg);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(b==mbno)
{
temp=i_code2;

f1.open("D:\\menu.txt",ios::in|ios::out|ios::app);
while(f1.read((char*)&pizza,sizeof(pizza)))
{
if(temp==i_code)
{
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";
total+=price;
break;
}

}
f1.close();
}
}
cout<<"\n\n"<<setw(20)<<"TOTAL COST FOR PIZZA IZZ RS:"<<total<<"\n";
}


if (found==0)
{
    if(b==99)
    goto MENU;
system("cls");
cout<<"File/Record Not Found!!\n Press any key to enter again.....";
getch();
goto Back;
}

MENU:
f1.close();
f2.close();
}


void order::del_rec()
{
system("color 7C");
searchAgain:             //GOTO STATEMENT 
found=0;
long long x;
char ch;

cout<<"Enter Mobile Number:"<<setw(10)<<"(ENTER 99 ANY TIME #TO #GO #BACK::)";
cin>>x;
f2.open("D://order.txt",ios::in|ios::out|ios::app);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(x==mbno)
{
cout<<"\n\nCustomer Name:"<<name;
cout<<"\nAddress:"<<add;
cout<<"\nContact No:"<<mbno;
temp=i_code2;
found=1;
}
}
f2.close();
if (found==0)
{
    if(x==99)
    goto MENU;
system("cls");
cout<<"File/Record Not Found!!\n Press any key to enter again.....";
getch();
goto searchAgain;
}

if(found==1)
cout<<"\n\nItem_Code"<<setw(18)<<"Pizza Name"<<setw(25)<<"Price"<<"\n\n";
f1.open("D:\\menu.txt",ios::in|ios::out|ios::app);

while(f1.read((char*)&pizza,sizeof(pizza)))
{
if(temp==i_code)
{
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";

}


}
     // MENU LOCAL GOTO Object;

f1.close();
MENU:  

f2.open("D://order.txt",ios::in);
f3.open("D://order1.txt",ios::in|ios::out|ios::app);
while(f2.read((char*)&pizza,sizeof(pizza)))
{
if(x==mbno)
continue;
f3.write((char*)&pizza,sizeof(pizza));
}
f2.close();
f3.close();
remove("D://order.txt");
rename("D://order1.txt","D://order.txt");






}

void menu::delPizzaMenu()
{
system("color 5F");
int tempIcode;
found=0;
f1.open("D://menu.txt",ios::in|ios::out|ios::app);
delPizzaMenu:
cout<<"Enter Pizza Code:";
cin>>tempIcode;
while(f1.read((char*)&pizza,sizeof(pizza)))
{
if(tempIcode==i_code)
{
cout<<i_code<<setw(25)<<p_name<<setw(20)<<price<<"\n";
found=1;
}
}
f1.close();
if(found!=1)
{
if(tempIcode==99)
goto delPizzaMenu1;
cout<<"Required Data Is Not Found!!!,\n   PRESS ANY KEY TO ENTER AGAIN(ENTER 99 To GO BACK):\n";
getch();
goto delPizzaMenu;
}


f1.open("D://menu.txt",ios::in);
f4.open("D://menu1.txt",ios::in|ios::out|ios::app);
delPizzaMenu1: // goto function
while(f1.read((char*)&pizza,sizeof(pizza)))
{
if(tempIcode==i_code)
continue;
f4.write((char*)&pizza,sizeof(pizza));
}
f1.close();
f4.close();
remove("D://menu.txt");
rename("D://menu1.txt","D://menu.txt");


}




main()
{
system("Color 6B");
char pass[256] = {0},c;
    char pass1[] = "mujtaba1@";
    int pos = 0,count=0;
    Sleep(300);
    cout<<setw(30)<<"               ============================================\n";
    Sleep(300);
    cout<<setw(45)<<"                           PIZZA MANAGEMENT SYSTEM\n";
    Sleep(300);
    cout<<setw(45)<<"                         CREATED BY- MOHAMMAD MUJTABA\n";
    Sleep(300);
    cout<<setw(45)<<"                               SECTION - K1613\n";
    Sleep(300);
    cout<<setw(45)<<"                                ROLL NO- B47\n";
    Sleep(300);
    cout<<setw(30)<<"               =============================================\n";
    Sleep(300);
    cout<<setw(30)<<"               =============================================\n";
    Sleep(300);
    cout<<setw(30)<<"                          LOGIN INTERFACE (AUTHORIZED)\n";
    Sleep(300);
    cout<<setw(30)<<"               =============================================\n\n";
    Sleep(300);
    login:  // GOTO FUNCTION
    
    cout<<"\nEnter Password (Max 3 attempts) : ";
    
    do {
        c = getch();

        if( isprint(c) ) 
        {
            pass[ pos++ ] = c;
            cout<<'*';
        }
        else if( c == 8 && pos )
        {
            pass[ pos-- ] = '\0';
            cout<<"\b\b";
            
        }
    } while( c != 13 );
    
    system("cls");
    cout<<"Please Wait System Is Verifing data";
    for(i=0;i<40;i++)
    {
    Sleep(59);
    cout<<"_";
}

    if( !strcmp(pass,pass1) )
        {
        system("cls");
        cout<<setw(40)<<"                  PLEASE WAIT WHILE PROGRAM IS LOADING>>\n";
            for(i=0;i<40;i++)
     {
cout<<"/\\";
Sleep(50);

            }
        }
    else
        {
  cout<<"\n Wrong Password!!!\n PRESS ANY KEY & TRY AGAIN";
  getch();
  count++;
  if(count==3)
  exit(42);
  else 
  goto login;
 }
pizza.home_page();
}

Saturday, 1 April 2017

C++ Binary Operator Overloading

//scope resolution
//terniry operator
//dot operator
//pointer 
//conditional these five operator can,t be overloaded.
//other operator
//ask for more....


#include<iostream>
using namespace std;
class abc
{
int a;
public:
void set(int x)
{


a=x;
}
abc operator+(abc c)
{
abc temp;
temp.a=a+c.a;
}
void show()
{
cout<<"A:"<<a;

}
};
main()
{
abc a,b,c;
a.set(5);
b.set(3);
//c=a+b
c=a+b;
c.show();

}



Amazon1Ads