elow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate Classes functionality. RectTest.cpp #define CATCH_CONFIG_MAIN #include "../Rect.h" #include TEST_CASE("Should be able to create a Rect with a default constructor") { Rect *rectangle = new Rect(); } TEST_CASE("getWidth should return the width of the rectangle") { Rect *rectangle = new Rect(); REQUIRE(0 == rectangle->getLength()); } TEST_CASE("getwidth should return with width of the rectangle") { Rect *rectangle = new Rect(); REQUIRE(0 == rectangle->getwidth()); } TEST_CASE("Should be able to create a rect with a width and height") { Rect *rectangle = new Rect(7,9); } TEST_CASE("By default a rect object should have a width and height of 0") { Rect *rectangle = new Rect(); CHECK(0 == rectangle->getLength()); CHECK(0 == rectangle->getwidth()); } TEST_CASE("Should be able to set the width") { Rect *rectangle = new Rect(); } TEST_CASE("Should get area with integer") { Rect rectangle; rectangle.setWidth(4); rectangle.setLength(3); REQUIRE(rectangle.area() == 12); } TEST_CASE("Should get perimeter with integer") { Rect rectangle; rectangle.setWidth(4); rectangle.setLength(3); REQUIRE(rectangle.perimeter() == 14); } TEST_CASE("Should get lengthIsGreater with integer") { Rect rectangle; rectangle.setWidth(4); rectangle.setLength(3); REQUIRE(!rectangle.lengthIsGreater()); } RectDriver.cpp: #include int main() { std::cout << "Hello, Rect Driver!" << std::endl; return 0; } Rect.cpp: #include "Rect.h" Rect.h : #ifndef Rect_h #define Rect_h #endif
elow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods.
For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate Classes functionality.
RectTest.cpp
#include "../Rect.h"
#include <catch2/catch_test_macros.hpp>
TEST_CASE("Should be able to create a Rect with a default constructor") {
Rect *rectangle = new Rect();
}
TEST_CASE("getWidth should return the width of the rectangle") {
Rect *rectangle = new Rect();
REQUIRE(0 == rectangle->getLength());
}
TEST_CASE("getwidth should return with width of the rectangle") {
Rect *rectangle = new Rect();
REQUIRE(0 == rectangle->getwidth());
}
TEST_CASE("Should be able to create a rect with a width and height") {
Rect *rectangle = new Rect(7,9);
}
TEST_CASE("By default a rect object should have a width and height of 0") {
Rect *rectangle = new Rect();
CHECK(0 == rectangle->getLength());
CHECK(0 == rectangle->getwidth());
}
TEST_CASE("Should be able to set the width") {
Rect *rectangle = new Rect();
}
TEST_CASE("Should get area with integer") {
Rect rectangle;
rectangle.setWidth(4);
rectangle.setLength(3);
REQUIRE(rectangle.area() == 12);
}
TEST_CASE("Should get perimeter with integer") {
Rect rectangle;
rectangle.setWidth(4);
rectangle.setLength(3);
REQUIRE(rectangle.perimeter() == 14);
}
TEST_CASE("Should get lengthIsGreater with integer") {
Rect rectangle;
rectangle.setWidth(4);
rectangle.setLength(3);
REQUIRE(!rectangle.lengthIsGreater());
}
int main() {
std::cout << "Hello, Rect Driver!" << std::endl;
return 0;
}
#define Rect_h
#endif
Trending now
This is a popular solution!
Step by step
Solved in 3 steps