Loading problems/LabFour_ChapterEleven.h 0 → 100644 +8 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 11/1/24. // #ifndef CURRENT_LABFOUR_CHAPTERELEVEN_H #define CURRENT_LABFOUR_CHAPTERELEVEN_H #endif //CURRENT_LABFOUR_CHAPTERELEVEN_H problems/LabFour_ChapterTen.h 0 → 100644 +120 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 11/1/24. // #include <ctime> #include <vector> using namespace std; // Chapter 10 /** * Implement three classes: * 0. labFour_pZero_Person represents a person with a name and a birthday. * 1. labFour_pZero_Student derives from labFour_pZero_Person and includes * a major. * 2. labFour_pZero_Instructor derives from labFour_pZero_Person and has * a salary. * Complete the class definitions and implementations, including constructors, * destructors, and an external override of stream operator<< and operator>> * to input and output each object. * * @example * labFour_pZero_Person Jim("James"); * Jim.setBirthday("2010-02-30"); // Jim's birthday is on February 30, 2010 * labFour_pZero_Student Jane("Jane","2020-03-15"); * Jane.setMajor(COMPUTER_ENGINEERING); * labFour_pZero_Instructor Gabi("Gabriella"); * Gabi.setBirthday("2000-01-03"); * Gabi.setSalary(100000); // $100,000 per year */ class labFour_pZero_Person; class labFour_pZero_Student; class labFour_pZero_Instructor; /** * Implement the following classes: * * labFour_pOne_GeometricThing - an abstract class representing a GeometricThing * * labFour_pOne_Quadrilateral - a concrete class representing an arbitrary quadrilateral * * labFour_pOne_Rectangle - a concrete class representing a rectangle * * labFour_pOne_Square - a concrete class representing a square * * labFour_pOne_Rhombus - a concrete class representing a rhombus * * labFour_pOne_Circle - a concrete class representing a cicle * Feel free to modify the inheritance structure, as you see fit. * * EACH concrete class must at least have methods with the signatures noted below * and also: * float getPerimeter() - returns the perimeter of the object * float getArea() - returns the area o the object */ class labFour_pOne_GeometricThing { public: class Point { public: Point(int Xcor, int Ycor) : x(Xcor), y(Ycor) {} int x; int y; }; /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumAreas(vector<labFour_pOne_GeometricThing> things); /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumPerimeters(vector<labFour_pOne_GeometricThing> things); }; class labFour_pOne_Quadrilateral : public labFour_pOne_GeometricThing { public: /** * Constructs a Quadrilateral on four points p0-p3, provided in clock-wise order. */ labFour_pOne_Quadrilateral(Point p0, Point p1, Point p2, Point p3); }; class labFour_pOne_Rectangle : public labFour_pOne_GeometricThing { /** * Constructs a rectangle. * @param UpperLeft The upper-left point of the rectangle. * @param length The length of the rectangle. * @param width The width of the rectangle. */ labFour_pOne_Rectangle(Point UpperLeft, int length, int width); }; class labFour_pOne_Square : public labFour_pOne_GeometricThing { /** * Constructs a square. * @param UpperLeft The upper-left point of the square. * @param length The length of a side of the square. */ labFour_pOne_Square(Point UpperLeft, int length); }; class labFour_pOne_Rhombus : public labFour_pOne_GeometricThing { /** * Constructs a rhombus. * @param UpperLeft The upper-left point of the rhombus. * @param length The length of a side of the rhombus. * @param angle The smallest angle between two sides of the rhombus. */ labFour_pOne_Rhombus(Point UpperLeft, int length, float angle); }; class labFour_pOne_Circle : public labFour_pOne_GeometricThing { /** * Constructs a circle. * @param center The center of the circle. * @param radius The radius of the circle. */ labFour_pOne_Circle(Point center, float radius); }; Loading
problems/LabFour_ChapterEleven.h 0 → 100644 +8 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 11/1/24. // #ifndef CURRENT_LABFOUR_CHAPTERELEVEN_H #define CURRENT_LABFOUR_CHAPTERELEVEN_H #endif //CURRENT_LABFOUR_CHAPTERELEVEN_H
problems/LabFour_ChapterTen.h 0 → 100644 +120 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 11/1/24. // #include <ctime> #include <vector> using namespace std; // Chapter 10 /** * Implement three classes: * 0. labFour_pZero_Person represents a person with a name and a birthday. * 1. labFour_pZero_Student derives from labFour_pZero_Person and includes * a major. * 2. labFour_pZero_Instructor derives from labFour_pZero_Person and has * a salary. * Complete the class definitions and implementations, including constructors, * destructors, and an external override of stream operator<< and operator>> * to input and output each object. * * @example * labFour_pZero_Person Jim("James"); * Jim.setBirthday("2010-02-30"); // Jim's birthday is on February 30, 2010 * labFour_pZero_Student Jane("Jane","2020-03-15"); * Jane.setMajor(COMPUTER_ENGINEERING); * labFour_pZero_Instructor Gabi("Gabriella"); * Gabi.setBirthday("2000-01-03"); * Gabi.setSalary(100000); // $100,000 per year */ class labFour_pZero_Person; class labFour_pZero_Student; class labFour_pZero_Instructor; /** * Implement the following classes: * * labFour_pOne_GeometricThing - an abstract class representing a GeometricThing * * labFour_pOne_Quadrilateral - a concrete class representing an arbitrary quadrilateral * * labFour_pOne_Rectangle - a concrete class representing a rectangle * * labFour_pOne_Square - a concrete class representing a square * * labFour_pOne_Rhombus - a concrete class representing a rhombus * * labFour_pOne_Circle - a concrete class representing a cicle * Feel free to modify the inheritance structure, as you see fit. * * EACH concrete class must at least have methods with the signatures noted below * and also: * float getPerimeter() - returns the perimeter of the object * float getArea() - returns the area o the object */ class labFour_pOne_GeometricThing { public: class Point { public: Point(int Xcor, int Ycor) : x(Xcor), y(Ycor) {} int x; int y; }; /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumAreas(vector<labFour_pOne_GeometricThing> things); /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumPerimeters(vector<labFour_pOne_GeometricThing> things); }; class labFour_pOne_Quadrilateral : public labFour_pOne_GeometricThing { public: /** * Constructs a Quadrilateral on four points p0-p3, provided in clock-wise order. */ labFour_pOne_Quadrilateral(Point p0, Point p1, Point p2, Point p3); }; class labFour_pOne_Rectangle : public labFour_pOne_GeometricThing { /** * Constructs a rectangle. * @param UpperLeft The upper-left point of the rectangle. * @param length The length of the rectangle. * @param width The width of the rectangle. */ labFour_pOne_Rectangle(Point UpperLeft, int length, int width); }; class labFour_pOne_Square : public labFour_pOne_GeometricThing { /** * Constructs a square. * @param UpperLeft The upper-left point of the square. * @param length The length of a side of the square. */ labFour_pOne_Square(Point UpperLeft, int length); }; class labFour_pOne_Rhombus : public labFour_pOne_GeometricThing { /** * Constructs a rhombus. * @param UpperLeft The upper-left point of the rhombus. * @param length The length of a side of the rhombus. * @param angle The smallest angle between two sides of the rhombus. */ labFour_pOne_Rhombus(Point UpperLeft, int length, float angle); }; class labFour_pOne_Circle : public labFour_pOne_GeometricThing { /** * Constructs a circle. * @param center The center of the circle. * @param radius The radius of the circle. */ labFour_pOne_Circle(Point center, float radius); };