TableBooking

DOCUMENTSTOOLSUTILITYFINANCIAL

Contract purpose

This smart contract manages table bookings for a restaurant. The manager can add to the contract all the tables from the restaurant and clients can book them.

Exposed methods and variables

manager address of the restaurant manager

addTables called by the manager when he wants to add tables to the contract, the tables can be added in batches of no more than 50. Also, all the added tables during one call have to share the same capacity and price.

parameter nametypedetails
idsinteger arraylist of unique IDs for the tables
capacityintegerthe capacity of the added tables
priceintegerthe amount the client needs to pay to book a table like this

getFreeTableID by calling this function, a client will receive the id and the price of a table which is big enough to fit the number of people given as a parameter. For example, for 3 people, only a table having the capacity 3 or 4 can be returned.

parameter nametypedetails
nrOfPeopleintegerthe number of people the table has to fit

bookTable payable function called by a client who wishes to book a certain table and emits the TableBooked event

parameter nametypedetails
idintegerthe id of the table

freeTable allows the manager to mark as available a previously booked table

parameter nametypedetails
idintegerthe id of the table

transferMoney allows the manager to transfer money from the contract's balance to his own account

parameter nametypedetails
amountintegerthe sum the manager wants to transfer

getBalance returns the balance of the contract when called by the manager

Events

TableBooked

parameter nametypedetails
clientethereum addressthe address of the client who booked the table
tableIDintegerid of the booked table
Buy
Reviewed by Modex
Buy Contract Test Contract

Create an account or login to purchase this smart contract