From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/my_nfts/person.hh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 graphs/cpp/my_nfts/person.hh (limited to 'graphs/cpp/my_nfts/person.hh') diff --git a/graphs/cpp/my_nfts/person.hh b/graphs/cpp/my_nfts/person.hh new file mode 100644 index 0000000..90a2e16 --- /dev/null +++ b/graphs/cpp/my_nfts/person.hh @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +#include "nft.hh" + +// A person +class Person +{ +public: + // Initiliaze its member attributes. + Person(const std::string& name, uint money); + + // Returns the list of NFTs it owns. + std::vector enumerate_nfts() const; + + // Give it a NFT. + void add_nft(NFT nft); + // Take away a NFT. + NFT remove_nft(const std::string& name); + + // Add money. + void add_money(uint money); + // Remove money, if possible. + bool remove_money(uint money); + + // Getters for money and name. + uint get_money() const; + const std::string& get_name() const; + +private: + std::string name_; + uint money_; + std::vector nfts_; +}; + +// Write informations about the person on the given stream. +std::ostream& operator<<(std::ostream& os, const Person& p); -- cgit v1.2.3