From af6a5c3ccf60bd083285f0db313c8c95bebb34ff Mon Sep 17 00:00:00 2001 From: amai83 Date: Thu, 1 Aug 2024 11:36:06 -0700 Subject: [PATCH 1/2] Code for documentation Adding code that needs improvement in documentation --- chatGPT/Amy_balloon.cpp | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 chatGPT/Amy_balloon.cpp diff --git a/chatGPT/Amy_balloon.cpp b/chatGPT/Amy_balloon.cpp new file mode 100644 index 0000000..0bb04a5 --- /dev/null +++ b/chatGPT/Amy_balloon.cpp @@ -0,0 +1,98 @@ +#include + +using namespace std; + +class Balloon +{ +protected: + static float PointsPerBalloon; + static float PointsMultiplier; + static float PointsTotal; + static int BalloonCount; + +public: + Balloon(); + virtual ~Balloon() = 0; + static int GetBalloonCount(); + static float GetPointTotal(); + virtual char GetIdentifier() const; +}; + +class RedBalloon : public Balloon +{ +public: + virtual char GetIdentifier() const; + ~RedBalloon(); +}; + +class BlueBalloon : public Balloon +{ +public: + virtual char GetIdentifier() const; + ~BlueBalloon(); +}; + +class YellowBalloon : public Balloon +{ +public: + virtual char GetIdentifier() const; + ~YellowBalloon(); +}; + +// Init static variables. +float Balloon::PointsPerBalloon = 1.0; +float Balloon::PointsMultiplier = 1.0; +float Balloon::PointsTotal = 1.0; +int Balloon::BalloonCount = 0; + +Balloon::Balloon() +{ + BalloonCount++; +} +Balloon::~Balloon() +{ + BalloonCount--; + PointsTotal = PointsPerBalloon * PointsMultiplier; +} +int Balloon::GetBalloonCount() +{ + return BalloonCount; +} +float Balloon::GetPointTotal() +{ + return PointsTotal; +} +char Balloon::GetIdentifier() const +{ + return '\0'; +} + +char RedBalloon::GetIdentifier() const +{ + return 'R'; +} +RedBalloon::~RedBalloon() +{ + PointsMultiplier = PointsMultiplier + 0.1; + cout << " Red Balloon - *POP* " << endl; +} + +char BlueBalloon::GetIdentifier() const +{ + return 'B'; +} + +BlueBalloon::~BlueBalloon() +{ + PointsPerBalloon = PointsPerBalloon + 0.1; + cout << " Blue Balloon - *POP* " << endl; +} + +char YellowBalloon::GetIdentifier() const +{ + return 'Y'; +} +YellowBalloon::~YellowBalloon() +{ + cout << " Yellow Balloon - *POP* " << endl; +} \ No newline at end of file From 0a578d68dcac46c9e9a97cc4956eed0ed23fbdf9 Mon Sep 17 00:00:00 2001 From: amai83 Date: Thu, 1 Aug 2024 14:22:18 -0700 Subject: [PATCH 2/2] Updated code Includes comments that explain the code --- chatGPT/Amy_balloon.cpp | 104 +++++++++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 18 deletions(-) diff --git a/chatGPT/Amy_balloon.cpp b/chatGPT/Amy_balloon.cpp index 0bb04a5..1605b92 100644 --- a/chatGPT/Amy_balloon.cpp +++ b/chatGPT/Amy_balloon.cpp @@ -2,97 +2,165 @@ using namespace std; +/** + * The Balloon class represents a generic balloon in the program. + * It contains static members to track the total points, points per balloon, + * points multiplier, and the total count of balloons. + * The class serves as a base class for specific types of balloons and + * defines virtual methods for getting the identifier of the balloon. + */ class Balloon { protected: - static float PointsPerBalloon; - static float PointsMultiplier; - static float PointsTotal; - static int BalloonCount; + static float PointsPerBalloon; // Points awarded per balloon + static float PointsMultiplier; // Multiplier applied to the points + static float PointsTotal; // Total points accumulated + static int BalloonCount; // Total count of balloon instances public: - Balloon(); - virtual ~Balloon() = 0; - static int GetBalloonCount(); - static float GetPointTotal(); - virtual char GetIdentifier() const; + Balloon(); // Constructor to initialize the balloon + virtual ~Balloon() = 0; // Pure virtual destructor + static int GetBalloonCount(); // Returns the total number of balloons + static float GetPointTotal(); // Returns the total points accumulated + virtual char GetIdentifier() const; // Returns the identifier of the balloon }; +/** + * The RedBalloon class represents a specific type of balloon with a unique identifier 'R'. + * It inherits from the Balloon class and overrides the GetIdentifier method. + * The destructor increases the points multiplier when a RedBalloon instance is destroyed. + */ class RedBalloon : public Balloon { public: - virtual char GetIdentifier() const; - ~RedBalloon(); + virtual char GetIdentifier() const; // Returns the identifier 'R' for RedBalloon + ~RedBalloon(); // Destructor for RedBalloon }; +/** + * The BlueBalloon class represents a specific type of balloon with a unique identifier 'B'. + * It inherits from the Balloon class and overrides the GetIdentifier method. + * The destructor increases the points per balloon when a BlueBalloon instance is destroyed. + */ class BlueBalloon : public Balloon { public: - virtual char GetIdentifier() const; - ~BlueBalloon(); + virtual char GetIdentifier() const; // Returns the identifier 'B' for BlueBalloon + ~BlueBalloon(); // Destructor for BlueBalloon }; +/** + * The YellowBalloon class represents a specific type of balloon with a unique identifier 'Y'. + * It inherits from the Balloon class and overrides the GetIdentifier method. + * The destructor provides a specific message when a YellowBalloon instance is destroyed. + */ class YellowBalloon : public Balloon { public: - virtual char GetIdentifier() const; - ~YellowBalloon(); + virtual char GetIdentifier() const; // Returns the identifier 'Y' for YellowBalloon + ~YellowBalloon(); // Destructor for YellowBalloon }; -// Init static variables. +// Initialize static variables. float Balloon::PointsPerBalloon = 1.0; float Balloon::PointsMultiplier = 1.0; float Balloon::PointsTotal = 1.0; int Balloon::BalloonCount = 0; +/** + * Constructor for the Balloon class. + * Increments the total balloon count when a new balloon instance is created. + */ Balloon::Balloon() { BalloonCount++; } + +/** + * Destructor for the Balloon class. + * Decrements the total balloon count when a balloon instance is destroyed. + * Updates the total points based on the points per balloon and the points multiplier. + */ Balloon::~Balloon() { BalloonCount--; PointsTotal = PointsPerBalloon * PointsMultiplier; } + +/** + * Returns the total number of balloon instances. + */ int Balloon::GetBalloonCount() { return BalloonCount; } + +/** + * Returns the total points accumulated from all balloons. + */ float Balloon::GetPointTotal() { return PointsTotal; } + +/** + * Returns the identifier of the balloon. + * This is a virtual method and should be overridden by derived classes. + */ char Balloon::GetIdentifier() const { - return '\0'; + return '\0'; // Default identifier (null character) } +/** + * Returns the identifier 'R' for RedBalloon. + */ char RedBalloon::GetIdentifier() const { return 'R'; } + +/** + * Destructor for RedBalloon. + * Increases the points multiplier by 0.1 and prints a pop message. + */ RedBalloon::~RedBalloon() { PointsMultiplier = PointsMultiplier + 0.1; cout << " Red Balloon - *POP* " << endl; } +/** + * Returns the identifier 'B' for BlueBalloon. + */ char BlueBalloon::GetIdentifier() const { return 'B'; } +/** + * Destructor for BlueBalloon. + * Increases the points per balloon by 0.1 and prints a pop message. + */ BlueBalloon::~BlueBalloon() { PointsPerBalloon = PointsPerBalloon + 0.1; cout << " Blue Balloon - *POP* " << endl; } +/** + * Returns the identifier 'Y' for YellowBalloon. + */ char YellowBalloon::GetIdentifier() const { return 'Y'; } + +/** + * Destructor for YellowBalloon. + * Prints a pop message specific to YellowBalloon. + */ YellowBalloon::~YellowBalloon() { cout << " Yellow Balloon - *POP* " << endl; -} \ No newline at end of file +}