Question: C++ Linux Confused with lab prompt, source code and instructions below // Implementation file for the FeetInches class #include // Needed for abs() #include FeetInches.h
C++ Linux
Confused with lab prompt, source code and instructions below

// Implementation file for the FeetInches class
#include // Needed for abs()
#include "FeetInches.h"
//************************************************************
// Definition of member function simplify. This function *
// checks for values in the inches member greater than *
// twelve or less than zero. If such a value is found, *
// the numbers in feet and inches are adjusted to conform *
// to a standard feet & inches expression. For example, *
// 3 feet 14 inches would be adjusted to 4 feet 2 inches and *
// 5 feet -2 inches would be adjusted to 4 feet 10 inches. *
//************************************************************
void FeetInches::simplify() {
if (inches >= 12) {
feet += (inches / 12);
inches = inches % 12;
} else if (inches
feet -= ((abs(inches) / 12) + 1);
inches = 12 - (abs(inches) % 12);
}
}
//**********************************************
// Overloaded binary + operator. *
//**********************************************
FeetInches FeetInches::operator +(const FeetInches &right) {
FeetInches temp;
temp.inches = inches + right.inches;
temp.feet = feet + right.feet;
temp.simplify();
return temp;
}
//**********************************************
// Overloaded binary - operator. *
//**********************************************
FeetInches FeetInches::operator -(const FeetInches &right) {
FeetInches temp;
temp.inches = inches - right.inches;
temp.feet = feet - right.feet;
temp.simplify();
return temp;
}
//*************************************************************
// Overloaded prefix ++ operator. Causes the inches member to *
// be incremented. Returns the incremented object. *
//*************************************************************
FeetInches FeetInches::operator ++() {
++inches;
simplify();
return *this;
}
//***************************************************************
// Overloaded postfix ++ operator. Causes the inches member to *
// be incremented. Returns the value of the object before the *
// increment. *
//***************************************************************
FeetInches FeetInches::operator ++(int) {
FeetInches temp(feet, inches);
inches++;
simplify();
return temp;
}
//************************************************************
// Overloaded > operator. Returns true if the current object *
// is set to a value greater than that of right. *
//************************************************************
bool FeetInches::operator >(const FeetInches &right) {
bool status;
if (feet > right.feet)
status = true;
else if (feet == right.feet && inches > right.inches)
status = true;
else
status = false;
return status;
}
//************************************************************
// Overloaded
// is set to a value less than that of right. *
//************************************************************
bool FeetInches::operator
bool status;
if (feet
status = true;
else if (feet == right.feet && inches
status = true;
else
status = false;
return status;
}
//*************************************************************
// Overloaded == operator. Returns true if the current object *
// is set to a value equal to that of right. *
//*************************************************************
bool FeetInches::operator ==(const FeetInches &right) {
bool status;
if (feet == right.feet && inches == right.inches)
status = true;
else
status = false;
return status;
}
//********************************************************
// Overloaded
// directly display FeetInches objects. *
//********************************************************
ostream& operator
strm
return strm;
}
//********************************************************
// Overloaded >> operator. Gives cin the ability to *
// store user input directly into FeetInches objects. *
//********************************************************
istream& operator >>(istream &strm, FeetInches &obj) {
// Prompt the user for the feet.
cout
This exercise is to update the IntegerList class we went over in lecture. Again you can get the source code of folder Ch14_Integertist 4 from Chapter14 at MyClasses. This contains the basic functions as well as the copy constructor and overloaded assignuent operator. What you will be creating is something that is called a safe array, one that will handle access violations and is resizeable. Add in the following functions and overloads. const IntegerList operator+ (const IntegerList \&right); int \&operator [] (const int \&); void resize (int); Here are descriptions of the functionality of these new methods. operator + The overload of the + operator is to concatenate the two lists. So if 11, 12, and 13 are lists, the command 13=11+12; will assign 13 the combined list of 11 and 12. operator[ ] This is already implemented but yous will make sotme changes. This method will simply return the element in the list at the position that comes in as the parameter. Since we want to handle access violations, if the position is less than 0 return the element at position 0 , if the position is larger than the array size minas 1 , return the element at the position array size minus 1 . resize(int) Resizes the array and copy the contents of the array. You need use new operator to dynamically allocate memory for a new array, and use delete to release the old array memory. If the new array size is smaller the data at the end of the old array will be lost. If the new array size is larger then the extra entries are to be set to 0 . Change the functions getElement and setElement so that they do not exit the program. Specifically, for getElement, if the position is less than 0 return the element at position 0 , if the position is larger than the array sioe minus 1 , return the element at the position array size minus 1. For, setElement, if the array position is valid then set the element and if the array position is invalid do nothing. Use the same makefile to compile the class and testing file attached. Connvile and run the testing file, your output should look like the printout below strm >> obj.feet;
// Prompt the user for the inches.
cout
strm >> obj.inches;
// Normalize the values.
obj.simplify();
return strm;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
