Question: C++ Programing Question: Use the class Diamond as describeed here to answer the questions below. The class Diamond is described by three data member: cut
C++ Programing Question:
Use the class Diamond as describeed here to answer the questions below. The class Diamond is described by three data member: 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 fuctions:
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 incompatable, and -1 when the second parameter is of greater value than the first.
An 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). Write a class specification for Diamond.
(B). 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). 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). 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).
(F). Write a program that takes values for the three attributes of the Diamond class as command-line parameters and uses these values to initialize a Diamond object called gem and then print gem to standard output using gems output operator. An example execution of how the output of your program might appears below.
NOTE:
Consider using atoi() (or stoi()) from
Gems data values must be written by gemss output operator, NOT the main program.
For simplicity you can assume the attributes are always given in the order demonstrated (i.e., cut, color, then clarity) and that they only valid values are provided. That is, this question DOES NOT require error handling on the command-line arguments.
a.out Excellent D 2
gem was initialized as Excellent D-2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
