Coat Check

TOOLSFINANCIALUTILITY

Contract purpose

This Smart Contract manages the coat check process for a venue as a night club or restaurant. The system parameters are set at contract creation (the total number of hangers, the price and the maximum number of items allowed per hanger). These parameters can be changed later by the manager. Each hanger has a unique number which is given to the client before he interacts with the contract.

Exposed methods and variables

manager the ethereum address of system manager, given as parameter at contract creation

nrOfHangers the total number of hangers in the coat check (parameter set in the constructor)

price the price for leaving your coat (set in the constructor)

availableHangers the total number of available hangers (not busy). Initially, it equals the nrOfHangers value

checkIn payable function called when leaving an item (number of left items must be less or equal to the maximum number of items allowed) at the coat check. The client has to send to the contract the same amount as the price set by the manager. It emits the HangerBusy event.

parameter nametypedetails
_nrintegerunique identifier of a hanger
_nrOfItemsintegerthe number of items left

checkOut function called by a client, who previously left items at coat check, to take his items and set the hanger as available. It emits the HangerAvailable event.

parameter nametypedetails
_nrintegerthe number of the hanger to be made available

changePrice called by the manager in case he wants to change the price of a hanger

parameter nametypedetails
newPriceintegerthe new price of a hanger

changeNrOfHangers allows the manager to change the number of hangers

parameter nametypedetails
valueintegerthe value by which the current number will be incremented or decremented (it is assumed that this value represents available hangers)
opintegerit has to be 0 or 1. If op =0 it will decrease the number of hangers with the value given as first parameter, this value has to be less than the value of availableHangers. IN case op=1, the number of hangers will be increased

changeMaxItems called by the manager in case he wants to change the maximum number of allowed items per hanger

parameter nametypedetails
newValueintegerthe new value

getHangerDetails returns the details about a specific hanger when called by the manager ( the address of the client, if it is busy or not, the number of items left on it, the check in time (unix epoch time))

parameter nametypedetails
_nrintegerthe number of the hanger to queried

transferMoney allows the owner 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

HangerBusy

parameter nametypedetails
numberintegerthe reference number of busy hanger
addressethereum addressthe account address of the client

HangerAvailable

parameter nametypedetails
numberintegerthe reference number of the new available hanger
Buy
Reviewed by Modex
Buy Contract Test Contract

Create an account or login to purchase this smart contract