Skip to content

Commit

Permalink
BookMyShow source code
Browse files Browse the repository at this point in the history
Ticket booking utility. This project only contains the back end code
  • Loading branch information
CodeWithKartik committed Apr 7, 2016
1 parent c40ebe3 commit 9d176c2
Show file tree
Hide file tree
Showing 36 changed files with 1,584 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Admin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "Admin.h"

class UserDatabase;

Admin::Admin(char *psswd):User(AdminName, psswd) {
//do nothing
}
Admin::Admin(const Admin &cpy):User(cpy) {
//do nothing
}
Admin::~Admin() {
//do nothing
}

24 changes: 24 additions & 0 deletions Admin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ADMIN_H_INCLUDED
#define ADMIN_H_INCLUDED

#include <iostream>
#include "User.h"
#include "Cinema.h"
#include "Movie.h"

class UserDatabase;
class MovieDatabase;
class CinemaDatabase;

static const char AdminName[] = "ADMIN";
class Admin : public User {
public:
Admin(char *psswd);
Admin(const Admin &cpy);
~Admin();

void UpdateUserDatabase(const char *username, char *new_psswd, UserDatabase &obj);
void UpdateMovieDatabase(const char id, MovieDatabase &mdb);
void UpdateCinemaDatabase(const char id, CinemaDatabase &mdb);
};
#endif // ADMIN_H_INCLUDED
77 changes: 77 additions & 0 deletions BookMyShow.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="BookMyShow" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/BookMyShow" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/BookMyShow" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="../Admin.cpp" />
<Unit filename="../Admin.h" />
<Unit filename="../BookingMgr.cpp" />
<Unit filename="../BookingMgr.h" />
<Unit filename="../Cinema.cpp" />
<Unit filename="../Cinema.h" />
<Unit filename="../CinemaDatabase.cpp" />
<Unit filename="../CinemaDatabase.h" />
<Unit filename="../Guest.cpp" />
<Unit filename="../Guest.h" />
<Unit filename="../LinkedList.cpp" />
<Unit filename="../LinkedList.h" />
<Unit filename="../LoginMgr.cpp" />
<Unit filename="../LoginMgr.h" />
<Unit filename="../Main.cpp" />
<Unit filename="../Member.cpp" />
<Unit filename="../Member.h" />
<Unit filename="../Movie.cpp" />
<Unit filename="../Movie.h" />
<Unit filename="../MovieDatabase.cpp" />
<Unit filename="../MovieDatabase.h" />
<Unit filename="../PersistentObjectUtility.cpp" />
<Unit filename="../PersistentObjectUtility.h" />
<Unit filename="../SeatingArrangement.cpp" />
<Unit filename="../SeatingArrangement.h" />
<Unit filename="../Slot.cpp" />
<Unit filename="../Slot.h" />
<Unit filename="../StdSeatingPlan.cpp" />
<Unit filename="../StdSeatingPlan.h" />
<Unit filename="../StdSlot.cpp" />
<Unit filename="../StdSlot.h" />
<Unit filename="../User.cpp" />
<Unit filename="../User.h" />
<Unit filename="../UserDatabase.cpp" />
<Unit filename="../UserDatabase.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
28 changes: 28 additions & 0 deletions BookingMgr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
#include "BookingMgr.h"
#include "Cinema.h"
#include "CinemaDatabase.h"

BookingMgr::BookingMgr(MovieDatabase &mdb, CinemaDatabase &cdb) {
ULI mid, cid;
int r,c;
std::cin>>mid>>cid>>r>>c;
t_mv = mdb.GetMovieByID(mid);
t_cn = cdb.GetCinemaByID(cid);
day = SUNDAY;
if (t_cn != NULL) {
std::vector<StdSeatingPlan> *splans = const_cast<std::vector<StdSeatingPlan> *>(t_cn->GetPlan());
std::vector<StdSlot> *sslots = const_cast<std::vector<StdSlot> *>(t_cn->GetSlots());
if (sslots != NULL && splans != NULL) {
for (register int i = 0; i < sslots[0].size(); i++) {
if (mid == sslots[0][i].GetMovieID()) {
show_ind = i;
t_sp = &splans[0][i];
t_sp->BookChairNo(r,c);
}
}
t_cn->SetPlan(splans); //Ideally this would be executed after payment manager have confirmed the payment.
//Also this would go on a separate thread
}
}
}
31 changes: 31 additions & 0 deletions BookingMgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef BOOKINGMGR_H_INCLUDED
#define BOOKINGMGR_H_INCLUDED

#include "Movie.h"
#include "Cinema.h"
#include "MovieDatabase.h"
#include "CinemaDatabase.h"

enum WeekDays {
SUNDAY = 0,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY
};

class BookingMgr {
protected:
//Ideally these variables should be stored on the UI side
Movie *t_mv;
Cinema *t_cn;
WeekDays day;
int show_ind;
StdSeatingPlan *t_sp;
public:
BookingMgr(MovieDatabase &mdb, CinemaDatabase &cdb);
};

#endif // BOOKINGMGR_H_INCLUDED
54 changes: 54 additions & 0 deletions Cinema.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "Cinema.h"
#include <cstring>

Cinema::Cinema(const char *nm, const char *add, CinemaType ct, bool isOp)
:name(std::strcpy((new char[strlen(nm)+1]), nm)), address(std::strcpy((new char[strlen(add)+1]), add)) {
cinemaID = -1;
type = ct;
isOperational = isOp;
nowShowing.clear();
for (register int i = 0; i < 7; i++) {
slots[i].clear();
plans[i].clear();
}
}
Cinema::Cinema(const Cinema &cpy):name(cpy.GetName()), address(cpy.GetAddress()) {
cinemaID = cpy.GetCinemaID();
type = cpy.GetType();
isOperational = cpy.GetOpStatus();
nowShowing = cpy.GetMoviesShowing();
const std::vector<StdSlot> *slts = cpy.GetSlots();
const std::vector<StdSeatingPlan> *plns = cpy.GetPlan();
for (register int i = 0; i < 7; i++) {
slots[i] = slts[i];
plans[i] = plns[i];
}
}
Cinema::~Cinema() {
delete[] name;
delete[] address;
}
std::ostream& operator<<(std::ostream& os, const Cinema *cn) {
os<<"CinemaId: "<<cn->GetCinemaID()<<"\n";
os<<"Name: "<<cn->GetName()<<"\n";
os<<"Address: "<<cn->GetAddress()<<"\n";
if (cn->GetType() == 0)
os<<"Type: PVR"<<"\n";
else if (cn->GetType() == 1)
os<<"Type: INOX"<<"\n";
else
os<<"Type: OTHERS"<<"\n";
os<<"Is Operational: "<<cn->GetOpStatus()<<"\n";
/*os<<"Now Showing: ";
for (register int i = 0; i < cn->GetMoviesShowing().size(); i++) {
//os<<cn->GetMoviesShowing()[i].Get
}
os<<"\n";*/
for (register int i = 0; i < 7; i++)
for (register int j = 0; j < cn->GetSlots()[i].size(); j++)
os<<cn->GetSlots()[i][j]<<"\n";
for (register int i = 0; i < 7; i++)
for (register int j = 0; j < cn->GetPlan()[i].size(); j++)
os<<cn->GetPlan()[i][j]<<"\n";
return os;
}
60 changes: 60 additions & 0 deletions Cinema.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef CINEMA_H_INCLUDED
#define CINEMA_H_INCLUDED

#include<iostream>
#include <vector>
#include "StdSlot.h"
#include "StdSeatingPlan.h"

enum CinemaType {
PVR = 0,
INOX,
OTHERS,
CMCOUNT
};
typedef unsigned long int ULI;

class Cinema {
protected:
ULI cinemaID;
const char *name;
const char *address;
CinemaType type;
bool isOperational;
std::vector<int> nowShowing;
std::vector<StdSlot> slots[7];
std::vector<StdSeatingPlan> plans[7];
public:
Cinema(const char *nm, const char *add, CinemaType ct, bool isOp = true);
Cinema(const Cinema &cpy);
~Cinema();

//Setters
void SetCinemaID(ULI id) {cinemaID = id;}
void SetType(CinemaType ct) {type = ct;}
void SetIsOperational(bool op) {isOperational = op;}
void AddMovie(int movieId) {nowShowing.push_back(movieId);}
void SetSlot(std::vector<StdSlot> slts[]) {
for (register int i = 0; i < 7; i++) {
slots[i] = slts[i];
}
}
void SetPlan(std::vector<StdSeatingPlan> plns[]) {
for (register int i = 0; i < 7; i++) {
plans[i] = plns[i];
}
}
//Getters
ULI GetCinemaID() const {return cinemaID;}
const char *GetName() const {return name;}
const char *GetAddress() const {return address;}
CinemaType GetType() const {return type;}
bool GetOpStatus() const {return isOperational;}
std::vector<int> GetMoviesShowing() const {return nowShowing;}
const std::vector<StdSlot> *GetSlots() const {return slots;}
const std::vector<StdSeatingPlan> *GetPlan() const {return plans;}

friend std::ostream& operator<<(std::ostream& os, const Cinema *cn);
};

#endif // CINEMA_H_INCLUDED
Loading

0 comments on commit 9d176c2

Please sign in to comment.