first semester files

This commit is contained in:
2024-02-22 14:31:08 -05:00
parent 0f26c9f73d
commit 2d4bbf49a4
242 changed files with 360411 additions and 0 deletions

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxBase", "wxBase\wxBase.vcxproj", "{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Debug|x64.ActiveCfg = Debug|x64
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Debug|x64.Build.0 = Debug|x64
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Debug|x86.ActiveCfg = Debug|Win32
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Debug|x86.Build.0 = Debug|Win32
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Release|x64.ActiveCfg = Release|x64
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Release|x64.Build.0 = Release|x64
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Release|x86.ActiveCfg = Release|Win32
{128B02C4-4E1C-4F63-8A0A-B32DD6B4A54B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {133E650D-4238-4F51-81BB-171D8152659E}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,24 @@
/*************************************************************************
* Name: Aidan Sharpe
* Course: Computer Science & Programming
* Class: CS04103 Section: 6
* Assignment Date: 12.13.2021
*
* File Names: cApp.h | cApp.cpp
* cMain.h | cMain.cpp
* ReservationDialog.h | ReservationDialog.cpp
* Restaurant.h | Restaurant.cpp
* README.txt |
***************************************************************************
* ID: CSNP Final Project
* Purpose: A reservation management system
* Key Features:
* - Create a walk-in reservation for a party of <N> people
* - Create a reservation for a party of <N> people at a certain time
* - See if tables are reserved or not
* - Check wait times for different party sizes
* - Edit reservations (change any component)
* - Add additional tables to the restaurant
*
* Created on top of wxWidgets cross-platform GUI framework for C++
***************************************************************************/

View File

@@ -0,0 +1,64 @@
#include "ReservationDialog.h"
using namespace std;
wxBEGIN_EVENT_TABLE(ReservationDialog, wxDialog)
EVT_BUTTON(10004, Ok)
EVT_BUTTON(10005, Cancel)
wxEND_EVENT_TABLE()
ReservationDialog::ReservationDialog() : wxDialog(nullptr, wxID_ANY, "Reserve Table", wxPoint(100, 100), wxSize(260, 240))
{
lblName = new wxStaticText(this, wxID_ANY, "*Reservation Name:", wxPoint(10, 10));
lblNumber = new wxStaticText(this, wxID_ANY, "*Phone Number:", wxPoint(10, 40));
lblSize = new wxStaticText(this, wxID_ANY, "*Party Size:", wxPoint(10, 70));
lblTime = new wxStaticText(this, wxID_ANY, "Reservation Time:", wxPoint(10, 100));
lblDate = new wxStaticText(this, wxID_ANY, "Reservation Date:", wxPoint(10, 130));
txtName = new wxTextCtrl(this, wxID_ANY, "", wxPoint(120, 10));
txtNumber = new wxTextCtrl(this, wxID_ANY, "", wxPoint(120, 40));
txtSize = new wxTextCtrl(this, wxID_ANY, "", wxPoint(120, 70));
txtTime = new wxTextCtrl(this, wxID_ANY, "", wxPoint(120, 100));
txtDate = new wxTextCtrl(this, wxID_ANY, "", wxPoint(120, 130));
btnOk = new wxButton(this, 10004, "OK", wxPoint(80, 165));
btnCancel = new wxButton(this, 10005, "Cancel", wxPoint(155, 165));
}
ReservationDialog::ReservationDialog(string name, string number, string size, string time, string date) : wxDialog(nullptr, wxID_ANY, "Reserve Table", wxPoint(100, 100), wxSize(260, 240))
{
lblName = new wxStaticText(this, wxID_ANY, "*Reservation Name:", wxPoint(10, 10));
lblNumber = new wxStaticText(this, wxID_ANY, "*Phone Number:", wxPoint(10, 40));
lblSize = new wxStaticText(this, wxID_ANY, "*Party Size:", wxPoint(10, 70));
lblTime = new wxStaticText(this, wxID_ANY, "Reservation Time:", wxPoint(10, 100));
lblDate = new wxStaticText(this, wxID_ANY, "Reservation Date:", wxPoint(10, 130));
txtName = new wxTextCtrl(this, wxID_ANY, name, wxPoint(120, 10));
txtNumber = new wxTextCtrl(this, wxID_ANY, number, wxPoint(120, 40));
txtSize = new wxTextCtrl(this, wxID_ANY, size, wxPoint(120, 70));
txtTime = new wxTextCtrl(this, wxID_ANY, time, wxPoint(120, 100));
txtDate = new wxTextCtrl(this, wxID_ANY, date, wxPoint(120, 130));
btnOk = new wxButton(this, 10004, "OK", wxPoint(80, 165));
btnCancel = new wxButton(this, 10005, "Cancel", wxPoint(155, 165));
}
// get values from text boxes and close
void ReservationDialog::Ok(wxCommandEvent& evt)
{
size = txtSize->GetValue().ToStdString();
time = txtTime->GetValue().ToStdString();
name = txtName->GetValue().ToStdString();
number = txtNumber->GetValue().ToStdString();
date = txtDate->GetValue().ToStdString();
Close();
evt.Skip();
}
// set values to default value and close
void ReservationDialog::Cancel(wxCommandEvent& evt)
{
canceled = true;
Close();
evt.Skip();
}

View File

@@ -0,0 +1,35 @@
#pragma once
#include <wx/wx.h>
#include <string>
using namespace std;
class ReservationDialog : public wxDialog
{
public:
ReservationDialog();
ReservationDialog(string, string, string, string, string);
void Ok(wxCommandEvent&);
void Cancel(wxCommandEvent&);
wxTextEntry* txtName = nullptr;
wxTextEntry* txtNumber = nullptr;
wxTextEntry* txtSize = nullptr;
wxTextEntry* txtTime = nullptr;
wxTextEntry* txtDate = nullptr;
wxStaticText* lblName = nullptr;
wxStaticText* lblNumber = nullptr;
wxStaticText* lblSize = nullptr;
wxStaticText* lblTime = nullptr;
wxStaticText* lblDate = nullptr;
wxButton* btnOk = nullptr;
wxButton* btnCancel = nullptr;
string size, name, number, date, time;
bool canceled;
wxDECLARE_EVENT_TABLE();
};

View File

@@ -0,0 +1,178 @@
#include "Restaurant.h"
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
Restaurant::Restaurant()
{
}
void Restaurant::addTable(int size)
{
Table t;
t.size = size;
tables.push_back(t);
}
bool Restaurant::reserveTable(int tNum)
{
return reserveTable(tNum, time(0));
}
bool Restaurant::reserveTable(int tNum, int time)
{
if (!isReserved(tNum, time))
{
Reservation r;
r.time = time;
tables.at(tNum).reservations.push_back(r);
return true;
}
return false;
}
void Restaurant::setFileName(string str)
{
fileName = str;
}
bool Restaurant::save()
{
if (fileName != "")
{
ofstream r;
r.open(fileName + ".txt");
r.clear();
r << "tables: " + tables.size() << endl;
for (int i = 0; i < tables.size(); i++)
{
r << "table: " << i << endl
<< "size: " << tables.at(i).size << endl
<< "reservations: " << tables.at(i).reservations.size() << endl;
for (int j = 0; j < tables.at(i).reservations.size(); j++)
{
r << tables.at(i).reservations.at(j).lastName << endl
<< tables.at(i).reservations.at(j).partySize << endl
<< tables.at(i).reservations.at(j).phoneNumber << endl
<< tables.at(i).reservations.at(j).time << endl;
}
}
r.close();
return true;
}
return false;
}
bool Restaurant::load(string fileName)
{
if (fileName != "")
{
tables.clear();
fstream r;
r.open(fileName + ".txt");
string line;
int tableCount;
}
return false;
}
// attempt to make a reservation for a party of <partySize> at <time> and return the index of the table that was reserved
int Restaurant::makeReservation(int partySize, int time, string name, string phoneNumber)
{
const int TOLERANCE = 2; // number of empty seats allowed at the table
for (int j = 0; j <= TOLERANCE; j++) // assign the party to the smallest table able to accomodate it
for (int i = 0; i < tables.size(); i++) // check each table to see if it meets desired parameters
// if the table can accomodate the party size within tolerance, make a reservation struct and append it to the tables list of reservations
if (tables.at(i).size == partySize + j && !isReserved(i, time))
{
Reservation r;
r.time = time;
r.partySize = partySize;
r.lastName = name;
r.phoneNumber = phoneNumber;
tables.at(i).reservations.push_back(r);
return i;
}
return -1; // return -1 as a flag to indicate no table could be reserved
}
int Restaurant::editReservation(int tNum, int resNum, int partySize, int time, std::string name, std::string number)
{
const int TOLERANCE = 2;
// clear the previous reservation
tables.at(tNum).reservations.erase(tables.at(tNum).reservations.begin() + resNum);
// create the new reservation
for (int j = 0; j <= TOLERANCE; j++)
for (int i = 0; i < tables.size(); i++)
if (tables.at(i).size == partySize + j && !isReserved(i, time))
{
Reservation r;
r.time = time;
r.partySize = partySize;
r.lastName = name;
r.phoneNumber = number;
tables.at(i).reservations.push_back(r);
return i;
}
return -1;
}
bool Restaurant::isReserved(int tNum)
{
return isReserved(tNum, time(0));
}
// check if a reservation starting at <time> will overlap any existing reservation slots for table <tNum>
bool Restaurant::isReserved(int tNum, int time)
{
vector<Reservation> reservations = tables.at(tNum).reservations;
for (int i = 0; i < reservations.size(); i++)
{
if (time + 3600 >= reservations.at(i).time && time <= reservations.at(i).time + 3600)
return true;
}
return false;
}
string Restaurant::tableStr(int tNum)
{
Table t = tables.at(tNum);
return "Table #" + to_string(tNum + 1) + " : " + to_string(t.size) + " : " + (isReserved(tNum) ? "Reserved" : "Not Reserved");
}
int Restaurant::waitTime(int partySize)
{
int timeOfOpening = -1;
const int TOLERANCE = 2; // number of empty seats allowed at the table
for (int j = 0; j <= TOLERANCE; j++) // assign the party to the smallest table able to accomodate it
for (int i = 0; i < tables.size(); i++) // check each table to see if it meets desired parameters
// if the table can accomodate the party size within tolerance
if (tables.at(i).size == partySize + j)
{
if (!isReserved(i))
return 0;
// make the next opening the new open time if it is the smallest so far
if (timeOfOpening == -1 || nextOpening(i) < timeOfOpening)
timeOfOpening = nextOpening(i);
}
return timeOfOpening;
}
// get the time of the next opening at the desired table
int Restaurant::nextOpening(int tNum)
{
int t = time(0);
Table table = tables.at(tNum);
for (int i = 0; i < table.reservations.size(); i++)
{
if (isReserved(tNum, t))
t = table.reservations.at(i).time + 3601;
else
return t;
}
return t;
}

View File

@@ -0,0 +1,42 @@
#pragma once
#include <vector>
#include <string>
struct Reservation
{
int time;
int partySize;
std::string phoneNumber;
std::string lastName;
};
struct Table
{
std::vector<Reservation> reservations;
int occupants;
int size;
};
class Restaurant
{
public:
Restaurant();
void addTable(int);
bool reserveTable(int);
bool reserveTable(int, int);
int makeReservation(int, int, std::string, std::string);
int editReservation(int, int, int, int, std::string, std::string);
int waitTime(int);
int partyOf(int);
int nextOpening(int);
bool isReserved(int, int);
bool isReserved(int);
void setFileName(std::string);
bool save();
bool load(std::string);
std::string tableStr(int);
std::string fileName;
std::vector<Table> tables;
};

View File

@@ -0,0 +1,18 @@
#include "cApp.h"
wxIMPLEMENT_APP(cApp);
cApp::cApp()
{
}
cApp::~cApp()
{
}
bool cApp::OnInit()
{
m_frame1 = new cMain();
m_frame1->Show();
return true;
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include <wx/wx.h>
#include "cMain.h"
class cApp : public wxApp
{
public:
cApp();
~cApp();
virtual bool OnInit();
private:
cMain* m_frame1 = nullptr;
};

View File

@@ -0,0 +1,336 @@
#include "cMain.h"
#include <iostream>
#include "ReservationDialog.h"
#include <ctime>
#include <fstream>
using namespace std;
wxBEGIN_EVENT_TABLE(cMain, wxFrame)
EVT_BUTTON(10000, ReserveTable)
EVT_BUTTON(10001, AddTable)
EVT_BUTTON(10003, Edit)
EVT_BUTTON(10007, WaitTime)
EVT_LISTBOX(10002, ShowTable)
EVT_LISTBOX(10006, EnableEdits)
wxEND_EVENT_TABLE()
string formatTime(int);
string formatDate(int);
int toUnixTime(string);
int toUnixTime(string, string);
string ltrim(const string&);
string rtrim(const string&);
string trim(const string&);
const int DAY = 86400, HOUR = 3600, MIN = 60, TIMEZONE = -5;
cMain::cMain() : wxFrame(nullptr, wxID_ANY, "Restaurant Manager", wxPoint(300, 300), wxSize(400, 180),
wxMINIMIZE_BOX | wxSTATIC_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
{
file = new wxMenu; file->Append(10007, "Save"); file->Append(10008, "Save As");
mnuMain = new wxMenuBar; mnuMain->Append(file, "&File");
//SetMenuBar(mnuMain);
btnParty = new wxButton(this, 10000, "Reservation", wxPoint(290, 105));
btnEdit = new wxButton(this, 10003, "Edit", wxPoint(290, 75), wxDefaultSize); btnEdit->Disable();
btnAddTable = new wxButton(this, 10001, "New Table", wxPoint(190, 105)); btnAddTable->SetFocus();
btnWaitTime = new wxButton(this, 10007, "Wait Time", wxPoint(190, 75));
lstTables = new wxListBox(this, 10002, wxPoint(20, 20), wxSize(150, 110));
lstReservations = new wxListBox(this, 10006, wxPoint(190, 20), wxSize(175, 50));
lblTable = new wxStaticText(this, wxID_ANY, "", wxPoint(190, 3), wxSize(100, 10));
lblTables = new wxStaticText(this, wxID_ANY, "Tables:", wxPoint(20, 3));
}
cMain::~cMain()
{
}
void cMain::AddTable(wxCommandEvent &evt)
{
// prompt user for table size
wxTextEntryDialog* msgAddTable = new wxTextEntryDialog(nullptr, "Size:", "Table Size", "");
msgAddTable->ShowModal();
wxString val = msgAddTable->GetValue();
string s = val.ToStdString();
// validate inpute
if (trim(s) != "")
{
restaurant.addTable(stoi(s)); // add table to restaurant
// update listbox text
lstTables->Clear();
for (int i = 0; i < restaurant.tables.size(); i++)
lstTables->AppendString(restaurant.tableStr(i));
}
evt.Skip();
}
void cMain::ShowTable(wxCommandEvent& evt)
{
// get selected item from list box
int pos = lstTables->GetSelection();
// update table label
if (pos >= 0)
{
Table table = restaurant.tables.at(pos);
lstReservations->Clear();
for (int i = 0; i < table.reservations.size(); i++)
lstReservations->AppendString(formatTime(table.reservations.at(i).time) + " to " + formatTime(table.reservations.at(i).time + 3600));
lblTable->SetLabel("Table #" + to_string(pos + 1) + ':');
}
btnEdit->Disable();
evt.Skip();
}
void cMain::Save(wxCommandEvent& evt)
{
restaurant.save();
}
// create a form to make a table reservation (also used to handle walk-ins)
void cMain::ReserveTable(wxCommandEvent& evt)
{
int pos = -1;
// create reservation form
ReservationDialog* msgReserveTable = new ReservationDialog();
msgReserveTable->ShowModal();
if (!msgReserveTable->canceled)
{
string val = trim(msgReserveTable->size);
string time = trim(msgReserveTable->time);
string date = trim(msgReserveTable->date);
string name = trim(msgReserveTable->name);
string phoneNumber = trim(msgReserveTable->number);
int unixTime = 0;
// assuming a party size is entered complete the form
if (val != "")
{
if (time != "")
if (date != "")
unixTime = toUnixTime(date, time);
else
unixTime = toUnixTime(time);
else
unixTime = std::time(0);
pos = restaurant.makeReservation(stoi(val), unixTime, name, phoneNumber);
}
if (pos < 0)
{
wxMessageDialog* msgNoRes = new wxMessageDialog(nullptr, "Unfortunately, the requested reservation could not be made.", "No Reservation");
msgNoRes->ShowModal();
}
lstTables->Clear();
for (int i = 0; i < restaurant.tables.size(); i++)
lstTables->AppendString(restaurant.tableStr(i));
btnEdit->Disable();
}
msgReserveTable->Destroy();
evt.Skip();
}
// edit a reservation
void cMain::Edit(wxCommandEvent& evt)
{
int pos = -1;
int tNum = lstTables->GetSelection(); tNum = (tNum >= 0) ? tNum : 0;
int resNum = lstReservations->GetSelection(); resNum = (resNum >= 0) ? resNum : 0;
Reservation r = restaurant.tables.at(tNum).reservations.at(resNum);
string name = r.lastName;
string phoneNumber = r.phoneNumber;
string size = to_string(r.partySize);
string time = formatTime(r.time);
string date = formatDate(r.time);
// create reservation form
ReservationDialog* msgReserveTable = new ReservationDialog(name, phoneNumber, size, time, date);
msgReserveTable->ShowModal();
if (!msgReserveTable->canceled)
{
name = trim(msgReserveTable->name);
phoneNumber = trim(msgReserveTable->number);
size = trim(msgReserveTable->size);
time = trim(msgReserveTable->time);
date = trim(msgReserveTable->date);
int unixTime = 0;
// assuming a party size is entered complete the form
if (size != "")
{
if (time != "")
if (date != "")
unixTime = toUnixTime(date, time);
else
unixTime = toUnixTime(time);
else
unixTime = std::time(0);
restaurant.editReservation(tNum, resNum, stoi(size), unixTime, name, phoneNumber);
}
if (pos >= 0)
{
Table table = restaurant.tables.at(pos);
string resData;
lstReservations->Clear();
for (int i = 0; i < table.reservations.size(); i++)
{
resData = table.reservations.at(i).lastName + ": ";
resData += formatTime(table.reservations.at(i).time) + " to " + formatTime(table.reservations.at(i).time + 3600);
lstReservations->AppendString(resData);
}
lblTable->SetLabel("Table #" + to_string(pos + 1) + ':');
}
lstTables->Clear();
for (int i = 0; i < restaurant.tables.size(); i++)
lstTables->AppendString(restaurant.tableStr(i));
}
msgReserveTable->Destroy();
evt.Skip();
}
void cMain::EnableEdits(wxCommandEvent& evt)
{
btnEdit->Enable();
}
void cMain::WaitTime(wxCommandEvent& evt)
{
int pos = -1;
// prompt user for party size
wxTextEntryDialog* msgWaitTime = new wxTextEntryDialog(nullptr, "Party Size:", "Wait Time", "");
msgWaitTime->ShowModal();
string val = msgWaitTime->GetValue().ToStdString();
if (val != "")
{
int wait = restaurant.waitTime(stoi(val));
// inform the user of a wait
if (wait > 0)
{
wxMessageDialog* msgWait = new wxMessageDialog(nullptr, "There is currently a wait until " + formatTime(wait), "Wait", wxOK);
msgWait->ShowModal();
}
else if (wait == 0)
{
wxMessageDialog* msgWait = new wxMessageDialog(nullptr, "There is currently no wait.", "Wait", wxOK);
msgWait->ShowModal();
}
// unsupported party size
else
{
wxMessageDialog* msgReservationError = new wxMessageDialog(nullptr, "Unfortunately, no tables can accomodate your party size.", "Reservation Error", wxOK | wxICON_ERROR);
msgReservationError->ShowModal();
}
}
}
string formatTime(int timestamp)
{
int days, hours, mins, secs;
string h, m, s;
days = timestamp / DAY; // find the number of days since 1970.01.01 00:00:00 GMT
timestamp -= days * DAY; // subtract that number of days worth of seconds
hours = timestamp / HOUR; // find the number of hours remaining
timestamp -= hours * HOUR; // subtract that number of hours in seconds
mins = timestamp / MIN; // find the number of minutes remaining
timestamp -= mins * MIN; // subtrace that number of minutes in seconds
secs = timestamp; // only seconds remain
hours = (hours + 24 + TIMEZONE) % 24; // convert to 24-hour time // make hours 12 when it is 0
h = to_string(hours); // convert hours to string
m = (to_string(mins).length() == 1 ? '0' + to_string(mins) : to_string(mins)); // add a leading 0 to minutes, if neccessary
s = (to_string(secs).length() == 1 ? '0' + to_string(secs) : to_string(secs)); // add a leading 0 to seconds, if neccessary
return h + ':' + m + ':' + s;
}
string formatDate(int timestamp)
{
timestamp += HOUR * TIMEZONE;
int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; // days in each month of the year
const float DAYS_PER_YEAR = 365.2425; // average number of days per year
int days = timestamp / DAY; // convert the timestamp from seconds to days
int year = days / DAYS_PER_YEAR; // convert the number of days into a number of years
days -= year * DAYS_PER_YEAR; // get the number of days left in the year
year += 1970; // add 1970 to the year, since UNIX time starts at the beginning of 1970
int day = 0, month = 0;
months[1] += !(year % 4) && (bool(year % 100) != !(year % 400)); // add a day to February if its a leap year
for (int i = 0; i < 12; i++)
{
month += 1; // incrament the month
day += months[i]; // incrament the number of days since the beginning of the year
if (days <= day) // check if the month is correct
{
day = months[i] - (day - days) + 1; // get the day of the month
break;
}
}
return to_string(month) + '/' + to_string(day) + '/' + to_string(year); // return in mm/dd/yyyy format
}
int toUnixTime(string time)
{
int today = std::time(0) - (std::time(0) % 86400);
if (time.find(':') == time.rfind(':'))
time += ":00";
int hours = stoi(time.substr(0, time.find(':'))) - TIMEZONE;
int mins = stoi(time.substr(time.find(':') + 1, time.rfind(':')));
int secs = stoi(time.substr(time.rfind(':') + 1));
return today + hours*3600 + mins*60 + secs;
}
int toUnixTime(string date, string time)
{
int t = 0;
int year = stoi(date.substr(date.rfind('/') + 1));
int day = stoi(date.substr(date.find('/') + 1, 2));
int month = stoi(date.substr(0, date.find('/')));
if (time.find(':') == time.rfind(':'))
time += ":00";
int hours = stoi(time.substr(0, time.find(':'))) - TIMEZONE;
int mins = stoi(time.substr(time.find(':') + 1, time.rfind(':')));
int secs = stoi(time.substr(time.rfind(':') + 1));
//Convert years to days
t = (365 * year) + (year / 4) - (year / 100) + (year / 400);
//Convert months to days
t += (30 * month) + (3 * (month + 1) / 5) + day;
//Unix time starts on January 1st, 1970
t -= 719561;
//Convert days to seconds
t *= 86400;
//Convert hours to seconds
t += hours * 3600;
//Convert minutes to seconds
t += mins * 60 + secs;
return t;
}
const string WHITESPACE = " \n\r\t\f\v";
string ltrim(const string& s)
{
size_t start = s.find_first_not_of(WHITESPACE);
return (start == string::npos) ? "" : s.substr(start);
}
string rtrim(const string& s)
{
size_t end = s.find_last_not_of(WHITESPACE);
return (end == string::npos) ? "" : s.substr(0, end + 1);
}
string trim(const string& s) {
return rtrim(ltrim(s));
}

View File

@@ -0,0 +1,35 @@
#pragma once
#include "wx/wx.h"
#include "Restaurant.h"
class cMain : public wxFrame
{
public:
cMain();
~cMain();
public:
wxButton* btnParty = nullptr;
wxButton* btnEdit = nullptr;
wxButton* btnClear = nullptr;
wxButton* btnAddTable = nullptr;
wxButton* btnWaitTime = nullptr;
wxListBox* lstTables = nullptr;
wxListBox* lstReservations = nullptr;
wxStaticText* lblTable = nullptr;
wxStaticText* lblTables = nullptr;
wxMenuBar* mnuMain = nullptr;
wxMenu* file = nullptr;
Restaurant restaurant = Restaurant();
void AddTable(wxCommandEvent& evt);
void ShowTable(wxCommandEvent& evt);
void ReserveTable(wxCommandEvent& evt);
void EnableEdits(wxCommandEvent& evt);
void Edit(wxCommandEvent& evt);
void Save(wxCommandEvent& evt);
void WaitTime(wxCommandEvent& evt);
wxDECLARE_EVENT_TABLE();
};

View File

@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by wxBase.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,4 @@
ables:
table: 0
size: 5
reservations: 0

View File

@@ -0,0 +1,60 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cApp.h" />
<ClInclude Include="cMain.h" />
<ClInclude Include="ReservationDialog.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Restaurant.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cApp.cpp" />
<ClCompile Include="cMain.cpp" />
<ClCompile Include="ReservationDialog.cpp" />
<ClCompile Include="Restaurant.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="wxBase.rc" />
</ItemGroup>
<ItemGroup>
<Text Include="README.txt" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{128b02c4-4e1c-4f63-8a0a-b32dd6b4a54b}</ProjectGuid>
<RootNamespace>wxBase</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(WXWIN)\include;$(WXWIN)\include\msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(WXWIN)\lib\vc_lib;</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cApp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cMain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Restaurant.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ReservationDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cApp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Restaurant.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ReservationDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="wxBase.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Text Include="README.txt" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>