.Open pages 243-250 Example of Object Oriented Programming . Project 7 Due in . We will skip 233-242 .Open Reading 7.5 An Object Oriented example . Introduction A complete $OO example -- a blackjack-like game. . page 253 Declaring suit and Card You may want to review enumerations .See http://csci.csusb.edu/dick/cs201/14.html#5.8 Enumeration types Error in declaration of class Card .As_is Card(suit = clubs, int = 1); should be .As_is Card(suit ss = clubs, int = 1); . page 244 -- declaration of CardStack . page 245 -- definition of CardStack functions . page 245 -- coding error In place of .As_is for(suit s=clubs; s starts search the compilers standard library for a file called "iostream". The .As_is #include "myFile.cpp" starts the search in the same directory as the file in shich you types the #include line. Only after filing to find it, does it search the standard libraries. . What exactly does the computer do with int counter = sqrt(n) when n is not a perfect square Lets try .As_is int counter = sqrt(17); .List First the computer makes space for one int in RAM with the name "counter". Then it preceeds to find the intial value to store in it. Since 'sqrt' is a function that needs a double to work on, the computer converts 17 into a double -- 17.000000. The sqrt function works on 17.00000 and produce a good approximation to the square root of 17. Something like 4.1231056... Next the double 4.1231056... coerced to fit into an int slot. To do this it is rounded off to 14. This will be to the closest integer to the double number. The rounded value 4 is placed in the memory area called counter. .Close.List Notice this hard-to-remember fact: the expression on the right of '=' is evaluated the same way whatever the variable is on the left of the assignment. After the value is found it is made to fit the variable. . With nested for loops do you do the whole of the second loop inside the first one Yes. If you see code like this .As_is for(A; B; C) .As_is for(D; E; F) .As_is G then the sequence of events is like this .As_is A; B; D; (E; G; F; E; G; F; ) !E; C .As_is B; D; (E; G; F; E; G; F; ) !E; C .As_is B; D; (E; G; F; E; G; F; ) !E; C .As_is !B; . How do you get a program to pick a card at random The function 'rand' is used in C++. All other languages have a similar function. They work as random as it gets. The book has a very good example of rand. . What are enumeration types .See ./14.html#5.8 Enumeration types . In what situations does having constant object benefit a programmer When you have an object that must not, even by accident, change or mutate. . I didn't understand friends They are for Thursday. .See ./18.html#8.3 Friends . What is the inheritance concept This is part of CS202: .See ../cs202/inheritance.html . How do objects oriented programming relate to data mapping Interesting question. First both data bases and $OO are inspired by making the software reflect the real world. You can even use UML diagrams (with no operations) to describe a data base. Second they have totally different theories. Most databases these days are "Relational" -- organized in tables connected by keys (values of attributes). In OOP we use the addresses (pointers) of data to connect and relate the objects. There are some data bases that over some object-oriented features and so we may end up with a consistency between the two approaches. Rich now, however, most OO prgrams has a special set of classes -- the .Key persistance layer -- that know all about the data base the program uses but stops the other objects needing to know about the data base. This is deep stuff and we have several classes that touch on it. .Close Questions . Quiz 8 -- Program with a class and main . Lab 09 -- UML diagrams of Clock, Flight, Card, Cardstack, ... .Close