You may need to remove the system("pause"); statement to run it in a different environment.
The assignment is to modify the class implementation without changing the functionality.
Remove the feet and inches data members and replace them with one data member named total_inches. Re-implement all the class methods so they have he same functionality as originally. This means that any program written using the public members of the new class must produce exactly the same results as the original implementation.
2 #include
#include #include using namespace std; /** va ul Aw The FeetInches class holds distances measured in feet and inches. 10 11 class FeetInches { private: int feet; int inches; 13 // The number of feet // The number of inches /** The simplify method adjusts the values in feet and inches to conform to a standard measurement. void simplify() if (inches > 11) feet = feet + (inches / 12); inches = inches % 12; This constructor assigns o to the feet and inches fields. public: FeetInches) feet = 0; inches = 0; This constructor accepts two arguments which are assigned to the feet and inches fields. The simplify method is then called. @param f The value to assign to feet. @param The value to assign to inches. */ FeetInches(int f, int i) feet = f; inches = i; simplify(); The following is a copy constructor. It accepts a reference to another FeetInches object. The feet and inches fields are set to the same values as those in the argument object. @param object2 The object to copy. Feet Inches (const Feetinches& object2), feet = object2. feet; inches = object2.inches; The setFeet method assigns a value to the feet field. @param f The value to assign to feet. void setFeet(int f) feet = f; The setInches method assigns a value to the inches field. @param The value to assign to inches. void setInches(int i) inches = i; simplify(); getFeet method @return The value in the feet field. 99 100 int getFeet() 101 return feet; 102 103 104 105 106 107 getInches method @return The value in the inches fiel 108 109 110 111 int getInches() { 112 return inches; 113 114 115 116 print method 116 print method prints the distance as feet/inches 117 void print() cout feet > ft; cout > in; g. setFeet(ft); g.setInches(in); 170 171 172 173 cout > ft; cout > in; g. setFeet(ft); g.setInches (in); 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 cout #include #include using namespace std; /** va ul Aw The FeetInches class holds distances measured in feet and inches. 10 11 class FeetInches { private: int feet; int inches; 13 // The number of feet // The number of inches /** The simplify method adjusts the values in feet and inches to conform to a standard measurement. void simplify() if (inches > 11) feet = feet + (inches / 12); inches = inches % 12; This constructor assigns o to the feet and inches fields. public: FeetInches) feet = 0; inches = 0; This constructor accepts two arguments which are assigned to the feet and inches fields. The simplify method is then called. @param f The value to assign to feet. @param The value to assign to inches. */ FeetInches(int f, int i) feet = f; inches = i; simplify(); The following is a copy constructor. It accepts a reference to another FeetInches object. The feet and inches fields are set to the same values as those in the argument object. @param object2 The object to copy. Feet Inches (const Feetinches& object2), feet = object2. feet; inches = object2.inches; The setFeet method assigns a value to the feet field. @param f The value to assign to feet. void setFeet(int f) feet = f; The setInches method assigns a value to the inches field. @param The value to assign to inches. void setInches(int i) inches = i; simplify(); getFeet method @return The value in the feet field. 99 100 int getFeet() 101 return feet; 102 103 104 105 106 107 getInches method @return The value in the inches fiel 108 109 110 111 int getInches() { 112 return inches; 113 114 115 116 print method 116 print method prints the distance as feet/inches 117 void print() cout feet > ft; cout > in; g. setFeet(ft); g.setInches(in); 170 171 172 173 cout > ft; cout > in; g. setFeet(ft); g.setInches (in); 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 cout