The most I have understood is that if and switch statements are used to test code.

But I think my professor means something else. Note: The other I know of is assert.

"Develop test code that tests your implementation (edge cases should be covered).

Any help is much appreciated.

** PROBLEM **

Provide an implementation of the egg carton class described below. Develop test code that tests your implementation (edge cases should be covered). You should have three separate source code files similar to exercise 1.

+----------------------------------------------------------------+ | | | EggCarton | | | +----------------------------------------------------------------+ | | | data fields: | | - brownEggs : int | | - whiteEggs : int | | | +----------------------------------------------------------------+ | | | member functions: | | + EggCarton() //set initial values to 0 and 0 | | + EggCarton(brownEggs : int, whiteEggs : int) | | // set initial values to 0 and 0 if the total number | | // of eggs is larger 12 | | + addBrownEggs(n : int) : bool | | + addWhiteEggs(n : int) : bool | | + getTotalEggs() : int | | | +----------------------------------------------------------------+

Figure 1

The class structure for the EggCarton class is shown in Figure 1. Instances of this class represent egg cartons that can hold up to 12 eggs. The class provides functions to add white and brown eggs. All of the functions that modify the number of eggs in the carton return false if the operation cannot be done exactly as requested. For example, if there are 3 white eggs and 0 brown eggs, then addBrownEggs(10) returns false and the number of white eggs remains at 3 and brown eggs at 0. There is a member function called getTotalEggs, which returns the total number of white and brown eggs together. For example, if the carton has 1 brown and 2 white eggs, then getTotalEggs returns 3.

(Appropriate function comments are expected for all functions.)

#ifndef EGGCARTON_H #define EGGCARTON_H #include <iostream> using namespace std; class EggCarton { private: int brownEggs; int whiteEggs; public: EggCarton(); EggCarton(int, int); bool addBrownEggs(int); bool addWhiteEggs(int); int getTotalEggs(); }; #endif

#include <iostream> #include "EggCarton.h" using namespace std; EggCarton::EggCarton() { brownEggs = 0; whiteEggs = 0; } EggCarton::EggCarton(int brownEggs, int whiteEggs) { if (brownEggs + whiteEggs > 12) { brownEggs = 0; whiteEggs = 0; } } bool EggCarton::addBrownEggs(int n) { } bool EggCarton::addWhiteEggs(int n) { } int EggCarton::getTotalEggs() { cout << brownEggs + whiteEggs; }

#include <iostream> #include "EggCarton.h" #include "EggCarton.cpp" using namespace std; int main() { EggCarton egg; //egg.addBrownEggs(10); //egg.getTotalEggs(); return 0; }