Skip to content

Instantly share code, notes, and snippets.

@connorphill
Last active October 26, 2021 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connorphill/b16f606e2b0a3303e1feb7e29cba6494 to your computer and use it in GitHub Desktop.
Save connorphill/b16f606e2b0a3303e1feb7e29cba6494 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title HotelGreeting
/// @author Connor Phillips (blockchain@connorphillips.com)
/// @notice Purpose of the contract is to leave a greeting to a guest who has arrived
/// @dev All function calls are currently implemented without side effects
contract HotelGreeting {
struct Guest {
string guestName;
uint guests;
} // Struct
Guest public guest;
enum Status {
Booked,
Staying,
Departed
} // Enum
Status public status;
string private greeting; // State variable
/// @notice Display the greeting for a specific guest
function greet() public view returns (string memory, string memory, uint, Status) {
return (
greeting,
guest.guestName,
guest.guests,
status
);
}
/// @notice Setting the greeting for the hotel guest and their current status
/// @param _greeting Greeting for guest
/// @param _guestName Name of guest
/// @param _guests Number of guests staying in the room
/// @param _status The enum status of the guest at the moment
function setGreeting(string memory _greeting, string memory _guestName, uint _guests, Status _status) public {
greeting = _greeting;
guest = Guest(_guestName, _guests);
status = Status(_status);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment