summaryrefslogtreecommitdiff
path: root/graphs/cpp/my_nfts/auction.hh
diff options
context:
space:
mode:
Diffstat (limited to 'graphs/cpp/my_nfts/auction.hh')
-rw-r--r--graphs/cpp/my_nfts/auction.hh34
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_;
+};