A command-line client for interacting with "book" and "member" servers via XMLRPC calls. Servers were created by other students.

MemberType.h 1.8KB

    #ifndef __KAVAMA_FINAL_MEMBERTYPE__ #define __KAVAMA_FINAL_MEMBERTYPE__ #include <string> #include <map> #include <xmlrpc-c/base.hpp> const int MEMBERTYPE_DISCOUNT_BOOK_NUM = 10; class MemberType { private: std::string _id; std::string _firstName; std::string _lastName; int _booksBought; float _moneySpent; public: MemberType(); // ToXML :: Converts a MemberType into a XMLRPC-C Struct // This is marshalling the object ('linearlize' it) const xmlrpc_c::value_struct ToXML(); // FromXML :: Converts a XMLRPC-C Struct into a MemberType // This is marshalling the object (de-'linearlize' it) void FromXML(xmlrpc_c::value_struct const& params); // Methods that deal with private data members std::string ID(); void ID(std::string); std::string FirstName(); void FirstName(std::string); std::string LastName(); void LastName(std::string); int BooksBought(); void BooksBought(int); float MoneySpent(); void MoneySpent(float); // Specialized methods for dealing with Member Logic for a bookstore situation. // BuyBook :: If the book price is 0 to greater, adds a book to bought count // and adds the price of the book to the money spent total. // Pre: Price must be valid ( >= 0) // Post: Books bought and money spent incremented. void BuyBook(float price); // ReadyForDiscount :: Checks if the member is ready for a discount. True, if so. // Pre: Certain number of books bought. bool ReadyForDiscount(); // DiscountAmount :: If the member is ready for a discount, the amount to discount. // Pre: Member is discountable. // Post: Discount amount is returned, either positive number or 0. float DiscountAmount(); // DiscountRest :: Used to reset the users discount settings. // Pre: Member is ready for a discount. // Post: Money spent and books bought are now 0. bool DiscountReset(); }; #endif