.Open CS320/07 Data Types and Data Structures .Table .Row Prev 06 Names Chapter 5 lab06 C/C++ Scoping .Row Today ** Project Phase 1 UML of old+Proposed changes(10 pts) .Row Today 07 Data Types Chapter 6 lab07 C/C++ Data .Row Next 08 Expressions etc Chapter 7 not section 8 lab08 C/C++ Expressions .Close.Table . Project Phase 1 Due in at start of class .See ./projects.html#Project Phase 1 due class 07 . Preparation 1. Study chapter 6 together with the notes on UML below. 2. Answer review questions at end of chapter 6 . 3. Hand in 2 or more answers to review questions. . Notes Standard C++ comes with a large library (the STL) of powerful data types. CSCI 330 (Data Structures) is an in depth study of this material. . Decimal Data Types Decimal data is a very important data type becuase it is used to represent .Key money. Accountants require precise decimal arithmetic -- to avoid fraud. So, floating point is not an option. Integers don't capture the typical currencies division into .List dollars and cents pounds and pence francs and centime .Close.List Only COBOL let's describe money as a decimal fraction and also as two decimal integers: the dollars and the cents. Integer arithmetic using binary can also break the rules of accountancy. For example taking an annual salary of \$10,000 and representing it as an integer 10000, and dividing it by 12 to get the monthly salary means you get 833 per months.... or \$9996 total -- and your employee could pocket \$4. Most countries specify rules that pay more in some months and less in others so that the total is correct and each month is close to the mathematical division. . UML and Data Types The UML has four primitive data types: Real, Integer, Boolean, String. These are actually defined in the Object Constraint Language or .Key OCL .See ../samples/ocl.html for details. .Key Enumerations in the UML (6.4.1) are shown as a class with stereotype .As_is <> and with the values listed as attributes. In the \$OCL they are written: .As_is enum{ value1, value2, ...} Their values are written .As_is #Value1, #Value2, ... in the \$OCL. In place of .Key array types (6.5) we have multiplicities(0..*, 4..5, ...). Put them on attributes in square brackets and links. .As_is grade[30]:Grade There are also special \$OCL types: Collection, Set, Bag, and Sequence. .Key Record types (6.7) are UML classes with no operations and all attributes public. Composition is a good way to show fields in a record. .Image 07uml3.gif Fields in a Record .Key Unions (6.8) are best treated by generalizations and multiple inheritance. .Key Pointers (6.9) have no special UML type. Do not use "*" to indicate pointers in the UML! The aggregation link is the old way for saying that one type of data has a pointer that refers to an object of another type. Make sure that (1) the name of the pointer is the role, (2) there is an arrow head, and (3) the multiplicity is 0..1. However, aggregation is not really intended to model pointers. Modern UML users just use an association with an arrow to show a pointer. .Image 07uml2.gif Using Aggregation to model pointers .Image 07uml2a.png Using Association to model pointers . Chapter 6 in the UML .Image 07uml1.gif Concepts in Chapter 6 . Class Work .See http://www/dick/cs320/07q.html .Close . Lab Work .See ./lab/07.html . Next: Expressions .See ./08.html