From 24bdf39e6c21ab846f6c86803761d78a094e05c0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 26 May 2022 20:31:26 +0300 Subject: Added files from project 1 (mirror) --- .../Project 1/docs/html/classEventService.html | 678 +++++++++++++++++++++ 1 file changed, 678 insertions(+) create mode 100644 Year 1/Object-oriented Programming/Project 1/docs/html/classEventService.html (limited to 'Year 1/Object-oriented Programming/Project 1/docs/html/classEventService.html') diff --git a/Year 1/Object-oriented Programming/Project 1/docs/html/classEventService.html b/Year 1/Object-oriented Programming/Project 1/docs/html/classEventService.html new file mode 100644 index 0000000..3cabe28 --- /dev/null +++ b/Year 1/Object-oriented Programming/Project 1/docs/html/classEventService.html @@ -0,0 +1,678 @@ + + + + + + + +FMI Ticket System: EventService Class Reference + + + + + + + + + +
+
+ + + + + + +
+
FMI Ticket System +
+
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 1 | Project Topic 4 |
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
EventService Class Reference
+
+
+ +

Each EventService stores all events and a pointer to HallService. + More...

+ +

#include <EventService.h>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

+ EventService (const HallService *hs)
 Sets HallService pointer and initializes events List.
 
+ EventService (const HallService *hs, const Event *events, unsigned eventCount)
 Sets HallService pointer and copies values from events into events List.
 
StatusCode createEvent (int hallNumber, const String &name, const Date &date)
 Creates an Event, with the given hallNumber, name and date. More...
 
StatusCode cancelEvent (const char *name, const Date &date)
 Cancels an Event with the given name and date. More...
 
StatusCode reserveTicket (const char *name, const Date &date, const char *password, const char *note, const Ticket &ticket)
 Creates a Reservation for an Event by name and date. More...
 
StatusCode cancelTicketReservation (const char *name, const Date &date, const Ticket &ticket)
 Cancels a Reservation for a ticket. More...
 
StatusCode ticketIsReserved (const char *name, const Date &date, const Ticket &ticket)
 Whether a ticket is a reserved or not. More...
 
StatusCode buyTicket (const char *name, const Date &date, const Ticket &ticket, const char *password, String *reservationNoteOutput)
 Buys ticket, assuming it is reserved and stores the reservation note. More...
 
StatusCode buyTicket (const char *name, const Date &date, const Ticket &ticket)
 Buys ticket, assuming it isn't reserved. More...
 
String createSeatingString (const char *name, const Date &date, unsigned *seatsPerRow)
 Creates a special String for status of all seats in given Event (by name and date) and returns seatsPerRow in given pointer. More...
 
List< Event > queryMostWatched (unsigned topN)
 
List< Event > queryInsufficientlyVisited ()
 
StatusCode reportReservations (const char *name, const Date &date)
 Creates a report that lists all Events (with given name and date) and their reserved tickets. More...
 
StatusCode reportBoughtTickets (int hallNumber, const Date &start, const Date &end, bool all=false)
 Creates a report that Lists all Events (with given name and date) and number of bought tickets. More...
 
StatusCode load ()
 Loads Events from a database file. More...
 
StatusCode save ()
 Saves Events to a database file. More...
 
+

Detailed Description

+

Each EventService stores all events and a pointer to HallService.

+

Member Function Documentation

+ +

◆ buyTicket() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::buyTicket (const char * name,
const Date & date,
const Ticket & ticket 
)
+
+ +

Buys ticket, assuming it isn't reserved.

+

Calls buyTicket with Reservation, but sets password and noteOutput to nullptr.

Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+E_TicketAlreadyBought if A ticket for the given row and seat has already been bought
+
+E_TicketAlreadyReserved if The seat and row are reserved, but given password is nullptr
+
+E_WrongReservationPassword if The seat and row are reserved, but given password is incorrect
+
+Success otherwise
+ +
+
+ +

◆ buyTicket() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::buyTicket (const char * name,
const Date & date,
const Ticket & ticket,
const char * password,
String * reservationNoteOutput 
)
+
+ +

Buys ticket, assuming it is reserved and stores the reservation note.

+
Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+E_TicketAlreadyBought if A ticket for the given row and seat has already been bought
+
+E_TicketAlreadyReserved if The seat and row are reserved, but given password is nullptr
+
+E_WrongReservationPassword if The seat and row are reserved, but given password is incorrect
+
+Success otherwise
+ +
+
+ +

◆ cancelEvent()

+ +
+
+ + + + + + + + + + + + + + + + + + +
StatusCode EventService::cancelEvent (const char * name,
const Date & date 
)
+
+ +

Cancels an Event with the given name and date.

+
Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+Success otherwise
+ +
+
+ +

◆ cancelTicketReservation()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::cancelTicketReservation (const char * name,
const Date & date,
const Ticket & ticket 
)
+
+ +

Cancels a Reservation for a ticket.

+

Canceling a reservation doesn't require password and doesn't return the Reservation's note

+
Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+W_TicketHadNotBeenReserved Ticket hadn't been reserved in the first place
+
+Success otherwise
+ +
+
+ +

◆ createEvent()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::createEvent (int hallNumber,
const String & name,
const Date & date 
)
+
+ +

Creates an Event, with the given hallNumber, name and date.

+

Uses HallService pointer to get Hall from hallNumber

Returns
E_HallDoesntExist if hallNumber doesn't correspond to any Hall, saved in HallService
+
+E_EventWillOverlap if Event's date overlaps with another event in the same Hall
+
+Success otherwise
+ +
+
+ +

◆ createSeatingString()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
String EventService::createSeatingString (const char * name,
const Date & date,
unsigned * seatsPerRow 
)
+
+ +

Creates a special String for status of all seats in given Event (by name and date) and returns seatsPerRow in given pointer.

+

Each seat in the Hall of the Event is represented by a single character, where 'R' means the seat is reserved, 'B' means the seat is bought and ' ' if it's neither.

+
Returns
Empty String if No Event with the given name and date exists
+
+Proper String otherwise
+ +
+
+ +

◆ load()

+ +
+
+ + + + + + + +
StatusCode EventService::load ()
+
+ +

Loads Events from a database file.

+

Looks for file named "eventsDatabse.fmits", which is just a binary file, and then reads it with the "read" function in events List.

+
Returns
E_FileCouldNotBeOpened if The files couldn't be opened/Doesn't exist
+
+Success otherwise
+ +
+
+ +

◆ queryInsufficientlyVisited()

+ +
+
+ + + + + + + +
List< Event > EventService::queryInsufficientlyVisited ()
+
+
Returns
A List of events which have attracted sales of less than 10% of the Hall's seat
+ +
+
+ +

◆ queryMostWatched()

+ +
+
+ + + + + + + + +
List< Event > EventService::queryMostWatched (unsigned topN)
+
+
Returns
A List of topN most watched Events
+

Events are sorted from index 0 to last index decreasingly by number of watchers. Watchers count for an Event is the amount of bought tickets.

+

If there are less events than topN, all events are returned.

+ +
+
+ +

◆ reportBoughtTickets()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::reportBoughtTickets (int hallNumber,
const Date & start,
const Date & end,
bool all = false 
)
+
+ +

Creates a report that Lists all Events (with given name and date) and number of bought tickets.

+
Parameters
+ + + + +
hallNumberNumber of the Event's Hall
startStarting Date from which to take Events
endEnding Date until which to take Evnets (including)
+
+
+

Report is saved in a file named "boughtTickets.txt" in the current directory.

+

All Events are inserted into the file with the << operator and a setting of 0b01001.

+
Returns
E_FileCouldNotBeOpened if Report file couldn't be created
+
+Success otherwise
+ +
+
+ +

◆ reportReservations()

+ +
+
+ + + + + + + + + + + + + + + + + + +
StatusCode EventService::reportReservations (const char * name,
const Date & date 
)
+
+ +

Creates a report that lists all Events (with given name and date) and their reserved tickets.

+
Parameters
+ + + +
nameC-style string, if it is equal to "ALL", reservations from all Events on the given date will be reported
dateIf day, month and year are equal to 0, reservations from all dates will be reported
+
+
+

Report is saved in a file in the current directory, named "report-NAME-DATE.txt", where NAME is the given name, and DATE is the given date or "ALL" if the date is 0/0/0

+

All Events are inserted into the file with the << operator and a setting of 0b00101.

+
Returns
E_FileCouldNotBeOpened if Report file couldn't be created
+
+Success otherwise
+ +
+
+ +

◆ reserveTicket()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::reserveTicket (const char * name,
const Date & date,
const char * password,
const char * note,
const Ticket & ticket 
)
+
+ +

Creates a Reservation for an Event by name and date.

+
Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+E_TicketAlreadyBought if A ticket for the given row and seat has already been bought
+
+E_TicketAlreadyReserved if A reservation has already been placed on the given row and seat
+
+Success otherwise
+ +
+
+ +

◆ save()

+ +
+
+ + + + + + + +
StatusCode EventService::save ()
+
+ +

Saves Events to a database file.

+

Looks for file named "eventsDatabse.fmits", which is just a binary file, and then writes to it with the "write" function in events List.

+
Returns
E_FileCouldNotBeOpened if The files couldn't be opened
+
+Success otherwise
+ +
+
+ +

◆ ticketIsReserved()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
StatusCode EventService::ticketIsReserved (const char * name,
const Date & date,
const Ticket & ticket 
)
+
+ +

Whether a ticket is a reserved or not.

+
Returns
E_EventDoesNotExist if No Event with the given name and date exists
+
+W_TicketHadNotBeenReserved Ticket hadn't been reserved in the first place
+
+Success otherwise
+ +
+
+
The documentation for this class was generated from the following files: +
+ + + + -- cgit v1.3.1-23-gd82d