Expert Answers


CLICK HERE TO DOWNLOAD THIS ANSWER  INSTANTLY $18 Only

 

1. (TCO 3) Two common relationships exist between classes—“is a” and “has a”. What kind of concept does each relationship represent? Give real world examples that demonstrate each of the relationships.
2. (TCO 2) Given the following program description,
Program Description - You have been asked to create a program designed to keep track of the inventory in a person's house. The program must keep track of all items owned by the house's resident and their specific location in the house. A single room can contain any number of items and every item should have a unique ID to differentiate it from all the other items. (Points : 18)
• identify the required classes/objects necessary to achieve the program requirements;
• briefly describe any relationships that might exist between your classes; and
• briefly describe the overall hierarchy of your proposed classes.
3. (TCO 2) Define and implement the overloaded constructors that support the following test function for a Date class. The data members for the Date class are:
• year - integer number
• month - integer number
• day - integer number
int main()
{ Date d1(); //d1 will take all default values
Date d2(2011, 8, 2); //d2 will take all supplied values
Date d3(2011); //d3 will take supplied year, month and day will take default values
Date d4(2011, 9); //d4 will take supplied year and month, day will take default value
Date d5 = d2; //d5 will take the same value as d2
//the rest of the code
}
TCO 1) Examine the class definition. How many members does it contain?
class clockType
{
public:
void setTime(int, int, int);
void getTime() const;
void icrementSeconds();
void incrementMinutes();
void incrementHours();
private:
int hr;
int min;
int sec;
};
8
3
5
None of the above
2. (TCO 1) Which of the following statements is/are true?
A. The implementation details of a class can change, so they need to be visible.
B. An object is necessary to be defined before you can create a class.
C. The state of an object is defined as the attributes and behaviors of that object.
D. An interface of a class defines what messages an object can respond to.
All are true
None are true
Only A, C, and D are true
3. (TCO 2) Which of the following components of a class definition do not have a return type?
Public member methods
Accessor/mutator methods
Constructors
Private member methods
None of the above

12. (TCO 7) _____ enforce a(n) _____ which is a methodology used in object-oriented programming to forces programmers to adhere to certain "rules."
Abstract classes; contract
Static variables; hierarchy
Classes; transitive communication
Method signatures; encapsulation
None of the above
3. (TCO 4) Why might it be better to create a derived class instead of adding a few lines of code to an existing Class?
Simplifies testing
No need to re-test the previously written class
Saves time on debugging the program
All of the above
None of the above