diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/cpp/my_nfts/auction.hh | |
add: graphs et rushs
Diffstat (limited to 'graphs/cpp/my_nfts/auction.hh')
| -rw-r--r-- | graphs/cpp/my_nfts/auction.hh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/graphs/cpp/my_nfts/auction.hh b/graphs/cpp/my_nfts/auction.hh new file mode 100644 index 0000000..9a1d162 --- /dev/null +++ b/graphs/cpp/my_nfts/auction.hh @@ -0,0 +1,34 @@ +#pragma once + +#include "nft.hh" +#include "person.hh" + +// Smart contract to auction a NFT. +// It is a RAII class. +class Auction +{ +public: + // Start the auction with the given (non-null) NFT. + Auction(Person& organizer, NFT nft, uint initial_bid); + // Close the auction. + ~Auction(); + + // https://en.cppreference.com/w/cpp/language/rule_of_three#Rule_of_five + Auction(const Auction&&) = delete; + Auction(const Auction&) = delete; + Auction& operator=(const Auction&&) = delete; + Auction& operator=(const Auction&) = delete; + + // Allow a person to bid at the auction. + bool bid(Person& person, uint money); + + // Getters for the nft name and highest bid. + const std::string& get_nft_name() const; + uint get_highest_bid() const; + +private: + Person& organizer_; + NFT nft_; + Person* highest_bidder_; + uint highest_bid_; +}; |
