<commit_before><commit_msg>change line<commit_after>#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<fstream>
#include<string.h>
#include<process.h>
#include<ctype.h>
#include<dos.h>
#include <windows.h>
#include "graphics.h"

using namespace std;

int choice;
void graph(void);
//ڵ
int meal = 0;
int ballett = 0;
int Car_No = 0;

//ڵ
int People_no;

struct date
{
	int da_day;
	int da_mon;
	int da_year;
};


void delay(int x)
{
	Sleep(x);
};


void gotoxy(int x, int y)
{
	COORD Cur;
	Cur.X = x;
	Cur.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Cur);


};

void textcolor(int color_number)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_number);
}



void getdate(date *d)
{
	scanf_s("%d %d %d", d->da_day, d->da_mon, d->da_year);
}

void basic()
{
	int gd = DETECT, gm;
	initgraph(&gd, &gm, "");
	setcolor(4);
	rectangle(0, 0, 636, 476);
	rectangle(2, 2, 634, 474);
	line(247, 52, 384, 52);
	line(247, 50, 384, 50);
	setbkcolor(1);

}


void graph()
{
	int gd = DETECT, gm;
	initgraph(&gd, &gm, "");
	setcolor(4);
	rectangle(0, 0, 636, 476);
	rectangle(2, 2, 634, 474);
	line(247, 52, 384, 52);
	line(247, 50, 384, 50);
	setbkcolor(0);
	setcolor(10);
	line(172, 345, 400, 345);

}

class ROOMS
{
public:
	int roomNo;
	int roomType;
	int roomStatus;
	int roomCharges;
	//ҽڵ
	int grade;							//򰡿  
	void Database();
	void status();
	int findRoomNo(int TYPE);
	void bookRoom(int roomNo);
	unsigned long retRoomCharges(int roomNo);
	void releaseRoom(int roomNo);
}r;										//ROOMS r

class CUSTOMER
{
public:
	int Roomn;
	char name[30];
	char add[30];
	char phone[20];
	int daysStayed;
	int DAY, MONTH, YEAR;
	long amount;
	void searchRoomNo();
	void searchCust();
	void check_in();
	void check_out();
	void reports();
	void previous_Customer();
};
int DAY, MONTH, YEAR;



void ROOMS::Database()
{
	fstream fin("rooms", ios::binary | ios::in);
	fin.close();
	for (int i = 1;i <= 200;i++)
	{
		if (i<100)
		{
			r.roomNo = i;
			r.roomStatus = 0;
			r.roomCharges = 300;
			r.roomType = 0;
			fstream fout("rooms", ios::binary | ios::app);
			fout.write((char*)&r, sizeof(r));
			fout.close();
		}
		else if (i >= 101 && i <= 150)
		{
			r.roomNo = i;
			r.roomStatus = 0;
			r.roomCharges = 500;
			r.roomType = 1;
			fstream fout("rooms", ios::binary | ios::app);
			fout.write((char*)&r, sizeof(r));
			fout.close();
		}
		else if (i>150 && i <= 200)
		{
			r.roomNo = i;
			r.roomStatus = 0;
			r.roomCharges = 1000;
			r.roomType = 2;
			fstream fout("rooms", ios::binary | ios::app);
			fout.write((char*)&r, sizeof(r));
			fout.close();
		}
	}
}
void CUSTOMER::searchCust()
{
	system("cls");
	basic();
	struct date d;
	getdate(&d);
	DAY = d.da_day;
	MONTH = d.da_mon;
	YEAR = d.da_year;
	int flag = 0;
	char NAME[20];
	gotoxy(32, 3); cout << "H I L L   V I E W";
	gotoxy(26, 5); cout << "C U S T O M E R    D E T A I L";
	gotoxy(5, 15);cout << "Enter Customer's Name : ";
	gets_s(NAME);
	CUSTOMER c;
	fstream fin("cust", ios::binary | ios::in);
	while (fin.read((char*)&c, sizeof(c)))
	{
		if (strcmp(NAME, c.name) == 0)
		{
			flag = 1;
			gotoxy(40, 15);cout << "Room Number: " << c.Roomn;
			gotoxy(40, 16);cout << "Customer Name : " << c.name;
			gotoxy(40, 17);cout << "Address: " << c.add;
			gotoxy(40, 18);cout << "Phone No. : " << c.phone;
			gotoxy(40, 19);cout << "Check-in : " << c.DAY << "/" << c.MONTH << "/" << c.YEAR;
			break;
		}
	}
	fin.close();
	if (flag == 0)
	{
		gotoxy(40, 15);	cout << "No such Name Found !!!";
	}
	_getch();
	closegraph();
	restorecrtmode();
}

int ROOMS::findRoomNo(int TYPE)
{
	ROOMS r;
	int RNO, flag = 0;
	fstream fin("rooms", ios::binary | ios::in);
	while (fin.read((char*)&r, sizeof(r)))
	{
		if (TYPE == r.roomType)
		{
			if (r.roomStatus == 0)
			{
				RNO = r.roomNo;
				flag = 1;
				break;
			}
			else
				flag = 2;
		}
	}
	fin.close();
	if (flag == 0)
		return 0;				//findRoomNo 0 ȯѴٸ  ã  .
	else if (flag == 1)
		return RNO;				//findRoomNo ѹ ȯѴٸ    ִ.
	else if (flag == 2)
		return -1;				//findRoomNo -1̶   ̴
	return 0;
}


void CUSTOMER::searchRoomNo()					//ȣ  ˻ִ Լ
{
	system("cls");								//ȭ 
	basic();									//⺻簢׸
	struct date d;								//¥ ü
	getdate(&d);
	DAY = d.da_day;
	MONTH = d.da_mon;
	YEAR = d.da_year;							//¥,, ޾ƿ´
	int roomno, flag = 0;						//ȣ  roomno,  ߴ ߴ Ȯ flag 
	gotoxy(32, 3); cout << "H I L L  V I E W ";
	gotoxy(26, 5);cout << "C U S T O M E R   D E T A I L ";
	gotoxy(5, 15);cout << "Enter Room Number : ";
	cin >> roomno;								//ãϴ ȣ Է¹޾ roomno Էش.
	CUSTOMER c;
	fstream fin("cust", ios::binary | ios::in);	//fin  Է· ڴ.(оڴ.)
	while (fin.read((char *)&c, sizeof(c)))		//   ڵ带 аڴ.
	{
		if (roomno == c.Roomn)					// ã ϴ  Ͼȿ ִٸ
		{
			flag = 1;							// ִٸ flag = 1 ٲش.
			gotoxy(40, 15);cout << "Room Number: " << c.Roomn;
			gotoxy(40, 16);cout << "Customer Name : " << c.name;
			gotoxy(40, 17);cout << "Address: " << c.add;
			gotoxy(40, 18);cout << "Phone No. : " << c.phone;
			gotoxy(40, 19);cout << "Check-in : " << c.DAY << "." << c.MONTH << "." << c.YEAR;	//Ÿ 濡   ش.(  ̸, ּ, ȭȣ, üũγ¥)
			break;
		}
	}
	fin.close();								//fin  
	if (flag == 0)								//flag = 0̶° ã  ٴ 
	{
		gotoxy(40, 15);
		cout << "No such Room No. Found !!!";		// ã  ٰ 
	}
	_getch();																			//µڿ ȭ ٷ Ѿ ȵǰ   Է¹ ٸ Ѵ.
	closegraph();																		//׷ȸ带 ݰ ؽƮ ϰڴ.
	restorecrtmode();																	//graph ߴ  ȭ 带 Ѵ.
}


void CUSTOMER::reports()																//  ݿ  Լ
{
	system("cls");																		//ȭ .
	basic();																			//⺻ ȭǰ
	CUSTOMER c;																			//  ü c
	gotoxy(32, 3); cout << "H I L L   V I E W";
	gotoxy(21, 5);	cout << "C U S T O M E R  S T A Y    S U M M A R Y";
	int i = 11;
	unsigned  long AMOUNT = 0;															//
	fstream fin("detail", ios::binary | ios::in);										//fin
	gotoxy(7, 9);
	cout << "R.No NAME\t ADDRESS\t AMOUNT\t DT OF CHECK-IN\tDAYS STAYED";
	while (fin.read((char*)&c, sizeof(c)))												//  аڴ.
	{
		gotoxy(7, i);	cout << c.Roomn;
		gotoxy(12, i);	cout << c.name;
		gotoxy(23, i);	cout << c.add;													// ȣ ̸ ּ 
		gotoxy(37, i);
		if (c.amount == -1)
			cout << "N/A";																//ش׾.	
		else
		{
			cout << c.amount << "/=";
			AMOUNT = AMOUNT + c.amount;														//ȣ Ѽҵ
		}
		gotoxy(50, i);	cout << c.DAY << "/" << c.MONTH << "/" << c.YEAR;
		gotoxy(68, i);
		if (c.daysStayed == -1)
			cout << "N/A";																//ش׾.
		else
			cout << c.daysStayed;
		i++;
		if (i == 22)
		{
			i = 11;
			gotoxy(21, 5);	cout << "C U S T O M E R   S T A Y    S U M M A R Y";
			gotoxy(7, 9);
			cout << "R.No NAMEADDRESS AMOUNT";
			cout << "DT/OF CHECK-INDAYS STAYED";
			gotoxy(28, 23);
			cout << "<Press any key to continue>";
			_getch();
		}
	}
	gotoxy(27, 25);
	gotoxy(27, 25);	cout << "< Net Amount Rs.: " << AMOUNT << "/= >";						//ȣ Ѽҵ 
	fin.close();
	_getch();																		//µڿ ȭ ٷ Ѿ ȵǰ   Է¹ ٸ Ѵ.
	closegraph();																	//׷ȸ带 ݰ ؽƮ ϰڴ.
	restorecrtmode();																//graph ߴ  ȭ 带 Ѵ.
}
void ROOMS::status()																// ¸ ִ Լ
{
	system("cls");
	ROOMS r;																		//濡  ü r
	gotoxy(8, 9);	cout << "\tR O O M  S T A T U S";
	fstream fin("rooms", ios::binary | ios::in);
	gotoxy(5, 19);cout << "  R.No    Room Type  Room Charges   Status    Grade" << "\n\n";
	int maxPageSize = 25;															//ִ   25
	int initPageSize = 4;															// ʱⰪ 4
	for (int i = 1;i<200;i++)															// 200 ̹Ƿ int i=1 200
	{
		fin.read((char*)&r, sizeof(r));
		cout << "\t" << r.roomNo << "\t";

		if (r.roomType == 2)															//Deluxe  Ÿ 2̹Ƿ
		{
			cout << "Deluxe  " << "\t";
		}
		else if (r.roomType == 1)														//semi-deluxe  Ÿ 1̴
		{
			cout << "semi-deluxe" << "\t";
		}
		else                                                                        //Ѵ ƴѹ Ordinary̴.
		{
			cout << "Ordinary" << "\t";
		}
		cout << r.roomCharges << "\t";													//  ȭ鿡 ش.
		cout << r.grade << "\t";														//  ȭ鿡 ش.

		if (r.roomStatus == 1)															//roomStatus 1̶   or ̶ 
			cout << "Occupied" << "\n";
		else                                                                        //ƹ   ̹Ƿ -------- 
			cout << "--------" << endl;

		initPageSize++;																// ȭ鿡   ʱ  ++Ų
		if (initPageSize == maxPageSize) {                                           // ʱ   ִ   ٸ 
			initPageSize = 1;														//ʱ  1 ٽ ʱȭ Ų

			_getch();																//Է ٸ.
		}
	}
	fin.close();
	_getch();																		//µڿ ȭ ٷ Ѿ ȵǰ   Է¹ ٸ Ѵ.
}

void CUSTOMER::check_in()															// ࿡  Լ
{
	system("cls");
	int TYPE, roomno, flag;															//TYPE  Ÿ, roomno  ѹ, flag  ߴ° ߴ°  Լ̴.
	char c;
	struct date d;																	//¥ ϴ ü d
	getdate(&d);
	DAY = d.da_day;
	MONTH = d.da_mon;
	YEAR = d.da_year;																	//¥, ,  d ޾ش.
	ROOMS r;																		//濡   ϴ ü r
	basic();
	r.Database();
	gotoxy(32, 3); cout << "H I L L  V I E W";
	gotoxy(28, 5);cout << "C H E C K    I N";
	gotoxy(10, 10);cout << "<Enter:: '2' for Deluxe, '1' for Semi Deluxe and '0' for Ordinary>";
	gotoxy(5, 15);cout << "Enter Room Type : ";

	do {
		c = _getch();																	//
		if (c >= 48 && c <= 50) { cout << c;delay(2000); }									//
	} while (c<48 || c>50);															//

	switch (c)
	{
	case '0': TYPE = 0;break;
	case '1': TYPE = 1;break;
	case '2': TYPE = 2;break;
	}																				// c Է¹   Ÿ̹Ƿ!

	gotoxy(20, 24);
	roomno = r.findRoomNo(TYPE);														//findRoomNo Լ 
	gotoxy(20, 24);
	if (roomno == -1)																	//roomno -1̶    ٴ ̴.		
	{
		cout << "This Room Type is not available !!!";
		_getch();
		return;
	}
	else if (roomno == 0)																//roomno 0̶  ã  ٴ°
	{
		cout << "Invalid room number !!!";
		_getch();
		return;
	}
	else                                                                           // ã  ְ  ִ
	{
		CUSTOMER c;
		static char NAME[30], ADD[30], PHONE[20];
		fstream fout("cust", ios::binary | ios::app);								// ϴ Ͱ    ϵȴ.
		gotoxy(5, 16);	cout << "Enter the Name : ";
		gets_s(NAME);
		gotoxy(5, 17); cout << "Enter Address: ";
		gets_s(ADD);
		gotoxy(5, 18);	cout << "Enter Phone No. : ";
		gets_s(PHONE);
		gotoxy(5, 19); cout << "Enter the Car No. : "; cin >> Car_No;

		gotoxy(5, 20); cout << "Enter the people No. : "; cin >> People_no; //(ä)


		c.Roomn = roomno;
		c.daysStayed = -1;
		c.amount = -1;
		strcpy_s(c.name, NAME);
		strcpy_s(c.add, ADD);
		strcpy_s(c.phone, PHONE);													//̸, ּ, ȣ, ȣ Է¹޴´

		c.DAY = DAY;
		c.MONTH = MONTH;
		c.YEAR = YEAR;
		fout.write((char*)&c, sizeof(c));										//
		fout.close();															// ݴ´
	}
	r.bookRoom(roomno);															//
	closegraph();
	restorecrtmode();
}

void CUSTOMER::check_out()
{
	//ڵ
	_getch();																	//3 Էѵ ȭ ٷ Ѿ° ϱ 							
	system("cls");
	basic();
	int roomno, flag = 0;
	long double AMOUNT;
	gotoxy(32, 3); cout << "H I L L   V I E W";
	gotoxy(32, 5);	cout << "C H E C K  O U T";
	gotoxy(23, 14);	cout << "Enter Room No. to Vacate : ";
	cin >> roomno;
	CUSTOMER c;
	fstream fin("cust", ios::binary | ios::in);

	while (fin.read((char*)&c, sizeof(c)))
	{
		if (roomno == c.Roomn)
		{
			flag = 1;
			break;
		}
	}
	fin.close();
	if (flag == 0)
	{
		gotoxy(28, 17);
		cout << "The Room is Unoccupied !!!";
		_getch();
		return;
	}
	if (flag == 1)
	{
		ROOMS r;
		r.releaseRoom(roomno);
		AMOUNT = r.retRoomCharges(roomno);
	}
	fstream fin1("cust", ios::binary | ios::in);
	fstream fout1("temp", ios::binary | ios::out);
	while (fin1.read((char*)&c, sizeof(c)))
	{
		if (roomno == c.Roomn && c.daysStayed == -1)
		{
			int D;
			gotoxy(23, 16);	cout << "Enter No. of Days stayed : ";
			cin >> D;
			c.daysStayed = D;
			//ڵ
			if(People_no < 3)			c.amount = D*AMOUNT + meal;		//ұݾ = ӹ*Ǳݾ*(ο/2)+䰪 / 3̻϶ ߰ο 3̸϶ 󰡰
			else c.amount = (D*AMOUNT + meal)*(People_no/2);


			gotoxy(23, 18);	cout << "Total Charges are Rupees : " << c.amount;
			gotoxy(18, 20);  cout << "߷ 񽺸 Ͻó? ( : 1, ƴϿ : 2) : ";
			cin >> ballett;																						//߷񽺿   ballett
			system("cls");
			if (ballett == 1) {
				gotoxy(18, 10); cout << " ȣ " << Car_No << "߷  û Ϸ. Դϴ.";
				gotoxy(22, 12); cout << "ϼ̳?  ּ (1~10) : "; cin >> r.grade;
				gotoxy(26, 14); cout << "մϴ :) ȳ!";
			}
			else if (ballett == 2) { gotoxy(26, 11); cout << "մϴ :) ȳ!"; }
			fout1.write((char*)&c, sizeof(c));
			_getch();
			return;
		}
		else
			fout1.write((char*)&c, sizeof(c));
	}
	fin1.close();
	fout1.close();
	remove("cust");
	rename("temp", "cust");

	ofstream f1, f2;
	f1.open("temp", ios::binary | ios::out | ios::app);
	f2.open("detail", ios::binary | ios::out | ios::app);
	fstream fin2("cust", ios::binary | ios::in | ios::app);
	while (!fin2.eof())
	{
		fin2.read((char*)&c, sizeof(c));
		if (!fin2.eof())
		{
			if (roomno != c.Roomn)
			{
				f1.write((char*)&c, sizeof(c));
			}
			else
			{
				f2.write((char*)&c, sizeof(c));
			}
		}
	}
	fin2.close();
	f1.close();
	f2.close();
	remove("cust");
	rename("temp", "cust");

	_getch();
	closegraph();
	restorecrtmode();

}

void ROOMS::bookRoom(int RNO)
{
	ROOMS r;
	fstream fin("rooms", ios::binary | ios::in);
	fstream fout("temp", ios::binary | ios::out);
	while (fin.read((char*)&r, sizeof(r)))
	{
		if (RNO == r.roomNo)
		{
			gotoxy(22, 25);
			cout << "Room No '" << RNO << "' has been booked";
			r.roomStatus = 1;
			fout.write((char*)&r, sizeof(r));
		}
		else
			fout.write((char*)&r, sizeof(r));
	}
	fout.close();
	fin.close();
	remove("rooms");
	rename("temp", "rooms");
	_getch();
}
void ROOMS::releaseRoom(int RNO)
{
	ROOMS r;
	int NO_DAYS;
	fstream fin("rooms", ios::binary | ios::in);
	fstream fout("temp", ios::binary | ios::out);
	while (fin.read((char*)&r, sizeof(r)))
	{
		if (RNO == r.roomNo)
		{
			r.roomStatus = 0;
			fout.write((char*)&r, sizeof(r));
		}
		else
			fout.write((char*)&r, sizeof(r));
	}
	fin.close();
	fout.close();
	remove("rooms");
	rename("temp", "rooms");
}
unsigned long ROOMS::retRoomCharges(int RNO)
{
	ROOMS r;
	long double AMOUNT;
	fstream fin("rooms", ios::binary | ios::in);
	while (fin.read((char*)&r, sizeof(r)))
	{
		if (RNO == r.roomNo)
		{
			AMOUNT = r.roomCharges;
			break;
		}
	}
	fin.close();
	return AMOUNT;
}
void CUSTOMER::previous_Customer(void)
{
	system("cls");
	basic();
	CUSTOMER c;
	char NAME[30];
	gotoxy(32, 3); cout << "H I L L   V I E W";
	gotoxy(5, 6);cout << "Enter customer name: ";
	gets_s(NAME);
	fstream fin("detail", ios::binary | ios::in);
	while (fin.read((char*)&c, sizeof(c)))
	{
		if (strcmp(c.name, NAME) == 0)
		{
			gotoxy(26, 8);cout << "Room Number: " << c.Roomn;
			gotoxy(26, 9);cout << "Customer Name : " << c.name;
			gotoxy(26, 10);cout << "Address: " << c.add;
			gotoxy(26, 11);cout << "Phone No. : " << c.phone;
		}
	}
	_getch();
	closegraph();
	restorecrtmode();
}
void enter_password()
{
	system("cls");
	char pass[10], c;
	int i = 0;
	gotoxy(25, 18);cout << "Enter the password : ";
	do {
		c = _getch();
		if (c == 8) { cout << '\b' << ' ' << '\b';i--; }
		else if (c != 13) { cout << '*';pass[i] = c;i++; }
	} while (c != 13);
	pass[i] = '\0';

	if (strcmp(pass, "<PASSWORD>") == 0)
		return;
	gotoxy(28, 20);cout << "   WRONG PASSWORD    ";
	_getch();
	exit(0);
}


void main()
{
	basic();


	char c;

	textcolor(GREEN);
	void graph(void);


	void enter_password();

	enter_password();
	system("cls");
	struct date d;

	do
	{
		system("cls");
		graph();
		gotoxy(32, 3); cout << "H I L L   V I E W";
		gotoxy(5, 23); cout << "Designed and Created by";
		gotoxy(30, 24); cout << "<NAME>";
		gotoxy(30, 25); cout << "<NAME>";
		gotoxy(30, 26); cout << "<NAME>";
		gotoxy(5, 12);cout << "1. Search";
		gotoxy(5, 13);cout << "2. Check in";
		gotoxy(5, 14);cout << "3. Check out";
		gotoxy(5, 15);cout << "4. Room status";
		gotoxy(5, 16);cout << "5. Earnings";
		gotoxy(5, 17);cout << "6. Previous Customers";
		gotoxy(5, 18);cout << "0. Exit";
		gotoxy(30, 21);	cout << "Enter choice : ";
		do {
			c = _getch();
			if (c >= 48 && c <= 54) { cout << c; delay(500); }
		} while (c<48 || c>54);
		switch (c)
		{
		case '0':choice = 0;break;
		case '1': choice = 1;break;
		case '2':choice = 2;break;
		case '3':choice = 3;break;
		case '4':choice = 4;break;
		case '5':choice = 5;break;
		case '6':choice = 6;break;
		case '7':choice = 7;break;
		}
		closegraph();
		restorecrtmode();
		switch (choice)
		{
		case 1: {
			int choice;
			char ch;
			do
			{
				system("cls");
				graph();
				gotoxy(32, 3);cout << "H I L L   V I E W";
				gotoxy(32, 5);cout << "S E A R C H\n\n";
				gotoxy(5, 12);cout << "1. To search by NAME";
				gotoxy(5, 13);cout << "2. To search by ROOM NO.";
				gotoxy(5, 14);cout << "0. Exit";
				gotoxy(30, 21);cout << "Enter choice : ";
				do {
					ch = _getch();
					if (ch >= 48 && ch <= 50) { cout << ch;delay(500); }
				} while (ch<48 || ch>50);
				switch (ch)
				{
				case '0':choice = 0;break;
				case '1': choice = 1;break;
				case '2':choice = 2;break;
				}

				closegraph();
				restorecrtmode();
				switch (choice)
				{
				case 1: {
					CUSTOMER c;
					c.searchCust();
					break;
				}
				case 2: {
					CUSTOMER c;
					c.searchRoomNo();
					break;
				}
				}
			} while (choice != 0);
			break;
		}
		case 2: {
			CUSTOMER c;
			c.check_in();
			break;
		}

		case 3: {
			CUSTOMER c;
			c.check_out();
			break;
		}
		case 4: {
			ROOMS r;
			r.status();
			break;
		}
		case 5: {
			CUSTOMER c;
			c.reports();
			break;
		}
		case 6: {
			CUSTOMER c;
			c.previous_Customer();
			break;
		}

		}
	} while (choice != 0);

}
{'fraction_non_alphanumeric': 0.20641513787931234, 'fraction_numerical': 0.03576785508249683, 'mean_word_length': 2.18716675859533, 'pattern_counts': {'":': 0, '<': 321, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7262623', 'n_tokens_mistral': 9543, 'n_tokens_neox': 7822, 'n_words': 1893}