Question: 6. (15 points total) Use the class Diamond as described here to answer the questions below. The class Diamond is described by three data members:

6. (15 points total) Use the class Diamond as described here to answer the questions below. The class Diamond is described by three data members: cut (e.g., Ideal, Excellent), color (e.g. D, E, F), and clarity (an int from 0 to 10). The Diamond class also has the member functions: A three-parameter constructor taking initial values for each data member. An accessor and a mutator for the Cut attribute. A comparison operator > returning 1 when the first Diamond parameter is of greater value than the second, 0 when the Diamonds are incomparable, and -1 when the second parameter is of greater value than the first. An output operator << working naturally with C++ output streams to print the data members. NOTE: As typical, data members should NOT be pubically accessible outside the class. a. (6 pts) Write a class specification for Diamond

b. (3 pts) Write an implementation for the three parameter constructor as it would appear in the implementation file. NOTE: Use the constructors base initialization section for at least one of the attributes.

c. (3 pts) Write an implementation for >(d1,d2) as in the implementation file. NOTE: A Diamond is considered more valuable than another if BOTH its color AND clarity are smaller. For example, a Diamond with color D and clarity 1, (i.e, a D-1), is more valuable than an E-3, because D < E and 1 < 3. However, with Diamonds graded F-3 and D-5, > returns 0, because they are incomparable, neither is fundamentally more valuable than the other.

d. (3 pts) Write an implementation for the output operator. The operator should print the cut quality followed by the color and clarity values separated by a dash (e.g., Excellent D-1 or Good F-3).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!