{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}
{\f91\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}{\f92\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f94\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}
{\f95\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}{\f96\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f97\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}
{\f98\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}{\f107\fmodern\fcharset238\fprq1 Courier New CE;}{\f108\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f110\fmodern\fcharset161\fprq1 Courier New Greek;}
{\f111\fmodern\fcharset162\fprq1 Courier New Tur;}{\f112\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f113\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f114\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0;
\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext0 Normal;}{
\s1\ql \li0\ri0\sb240\sa60\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext15 heading 1;}{\s2\ql \li0\ri0\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon0 \snext0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}{\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
\snext15 Default;}{\s16\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Text body;}{\s17\ql \fi-283\li567\ri0\sa120\nowidctlpar
\tx567\aspalpha\faauto\rin0\lin567\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext17 Hanging indent;}{\s18\ql \li0\ri0\sb240\sa120\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Heading;}{\s19\ql \fi-360\li360\ri0\nowidctlpar\aspalpha\faauto\rin0\lin360\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext19 List;}{
\s20\ql \fi-360\li720\ri0\nowidctlpar\aspalpha\faauto\rin0\lin720\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext20 List 2;}{\s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext21 header;}{\s22\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext22 Table Contents;}{
\s23\qc \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon22 \snext23 Table Heading;}{\s24\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext24 Index;}{\s25\qc \li0\ri0\sb240\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs32\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext26 Title;}{
\s26\qc \li0\ri0\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Subtitle;}{\s27\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext27 footer;}{\s28\ql \li0\ri0\sb120\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext28 caption;}{\*
\cs29 \additive \cf1\lang0\langfe255\langfenp255 Numbering Symbols;}{\*\cs30 \additive \cf1\lang0\langfe255\langfenp255 WW-Default Paragraph Font;}{\*\cs31 \additive \cf1\lang0\langfe255\langfenp255 \sbasedon30 page number;}}{\info{\author CNRS}
{\operator CNRS}{\creatim\yr2003\mo8\dy29\hr23\min17}{\revtim\yr2003\mo12\dy5\hr2\min20}{\printim\yr2003\mo11\dy14\hr13\min4}{\version8}{\edmins6}{\nofpages2}{\nofwords713}{\nofchars4069}{\*\company CNRS-HSU}{\nofcharsws4997}{\vern8269}}
\margl1440\margr1440\margt1400\margb720 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\nolnhtadjtbl 
\fet0\sectd \sbknone\linex0\headery709\sectdefaultcl {\header \pard\plain \s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\fs16 CS 131 - Homework #12\tab \tab p. }
{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 2}}}{
\par }{\fs16 Fall 2003
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b CS 131 - Intro to Computer Science I - Fall 2003
\par LAB #12 EXERCISE and Homework #12
\par 
\par lab #12 exercise due: Friday, December 5th, END of lab
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b HW #12 due: Friday, December 12th, }{\b\ul beginning}{\b  of lab
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\ul LAB #12 EXERCISE
\par }{\ul 
\par }{Consider }{\b Point3}{ and }{\b ColoredPoint3}{ as discussed in lecture on Wednesday, December 3rd.
\par 
\par *\tab to help show that both }{\b Point3}{ and }{\b ColoredPoint3}{ are considered to be of type }{\b Point3}{, do the following:
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab copy all of the files in }{\b ~st10/131hw12_public}{ to your current working directory as follows:
\par \tab }{\f2 cp ~st10/131hw12_public/* .}{
\par }{\loch\af2 
\par \tab }{Compile Point3.cpp, ColoredPoint3.cpp, and dist.cpp as usual. (You can ignore the Grocery-related files for now; they are for HW #12 below.)}{\loch\af2 
\par }{
\par *\tab You may have noticed that you also copied over a file named }{\b allPoints.h}{
; this kluge of a header file #include's Point3.h, it includes a copy of dist's header (but not its #includes), and it includes a copy of ColoredPoint3's header (but not its #includes).
\par 
\par \tab Why? So that we can show that }{\b dist}{ can work with either Point3's or ColoredPoint3's.
\par 
\par *\tab To show this, make the following modifications to the simplified version of }{\b test_dist.cpp}{ that you copied over above:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab right now, test_dist.cpp #include's dist.h. This is a problem, because ColoredPoint3.h #include's Point3, and so does dist.h. To make all 3 work and play together, }{
\b replace}{ the #include for dist.h to instead be a #include for allPoints.h.
\par 
\par *\tab change }{\b p2}{ appropriately so that it is now an instance of }{\b ColoredPoint3}{ instead of a }{\b Point3}{.
\par 
\par *\tab NOTE that the call to dist in here then computes the distance between a Point3 and a ColoredPoint3 --- but that is okay, because ColoredPoint3 is a subclass of Point3, so its instances are also considered to be of type Point3.
\par }{\b 
\par }{*\tab Compile and link }{\b test_dist.cpp }{--- but, be careful: what .o files will be needed here?
\par 
\par }{*\tab Run test_dist and verify that the call to dist did indeed work as advertised. Then add your name to the "next" list on the board so that I can run your result and verify that it does compute the dist between a ColoredPoint3 and a Point3.
\par }{\b 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {If you complete the above successfully before lab is over, then you have successfully completed the lab exercise.}{\b 
\par }{\b\ul 
\par HOMEWORK #12:
\par 
\par }{\b 1.\tab }{When you copied over the files for the lab exercise, you also copied over some additional files related to a class }{\b  Grocery: Grocery.h, Grocery.cpp, and test_Grocery.cpp}{.
\par 
\par \tab You need to create two }{\b derived}{ }{\b classes}{ that have Grocery as a }{\b base}{ }{\b class}{:
\par 
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab derived class }{\b Coffee}{ needs to have:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab two additional member variables:
\par }\pard \s15\ql \fi-420\li1710\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1710\itap0 {*\tab one that indicates the variety of coffee bean, and
\par *\tab one that indicates if this is instant, whole bean, or ground.
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {
\par *\tab those contents that should be created for a derived class that does not involve pointers or dynamic variables (as discussed in lecture and in the course text)
\par 
\par *\tab a redefined overloaded  == operator
\par }{\b 
\par }{*\tab a public member function }{\b isInstant}{, that returns true if this coffee instance is an instant coffee and returns false otherwise.
\par 
\par *\tab an appropriately-redefined version of member function }{\b printItem}{
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {
\par *\tab derived class }{\b IceCream}{ needs to have:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {* \tab one additional member variable, that indicates the flavor of the ice cream.
\par 
\par *\tab those contents that should be created for a derived class that does not involve pointers or dynamic variables
\par 
\par *\tab  a redefined overloaded operator ==
\par 
\par *\tab an appropriately-redefined version of member function }{\b printItem}{
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\tab To test your classes  Coffee and IceCream:
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab create }{\b test_Coffee.cpp}{,analogous to test_Grocery.cpp, that performs all of the Grocery tests on Coffee instances, }{\b AND}{ also perfor
ms appropriate additional tests on its "additional" elements.
\par 
\par *\tab create }{\b test_IceCream.cpp}{, analogous to test_Grocery.cpp, that performs all of the Grocery tests on IceCream instances, }{\b AND}{ also performs appropriate additional tests on its "additional" elements.
\par 
\par *\tab BUT --- Coffee and IceCream instances are instances of type Grocery, too! SO, to underscore this, ALSO add the following to }{\b test_Grocery.cpp}{:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab create at least one instance of }{\b Coffee}{ and at least one instance of }{\b IceCream}{;
\par 
\par *\tab write a call to }{\b isCheaperThan}{ that compares the }{\b Coffee}{ instance to the }{\b IceCream}{ instance;
\par *\tab write a call to }{\b isCheaperThan}{ that compares }{\b either}{ the }{\b Coffee}{ instance or the }{\b IceCream}{ instance to one of the }{\b Grocery}{ instances;
\par *\tab }{\b print}{ the results to the screen in such a way that the reader can easily tell if these tests had the expected results or not;
\par }{\b 
\par }{*\tab }{\b TO AVOID RE-DEFINITION}{ of }{\b Grocery}{ when you try to #include Coffee and IceCream, perform the following kluge: in a file }{\b Combined.h}{, #include "Grocery.h" and <string>, and then }{\b paste}{ yo
ur versions of IceCream's and Coffee's class definitions under that. In }{\b test_Grocery.cpp}{, then #include }{\b "Combined.h"}{ in place of Grocery.h, Coffee.h, and IceCream.h.}{\b 
\par 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\tab When these are complete and debugged, you will e-mail me your final versions of }{\b Coffee.h}{, }{\b Coffee.cpp}{, }{\b test_Coffee.cp}{, }{\b IceCream.h}{, }{\b 
IceCream.cpp}{, and }{\b test_IceCream.cpp}{, }{\b Combined.h, }{and the final version of }{\b test_Grocery.cpp}{.}{\b 
\par 
\par }\pard \s15\ql \li-15\ri0\nowidctlpar\aspalpha\faauto\rin0\lin-15\itap0 {\b 
\par }{\b\ul 
\par }}