. 07 Designing Classes . Previous --introducing objects and classes .See ./06.html .Open Prepare . 3.10 Validating Data with set Functions A class must always protect its objects from abuse. A class defines a collection of functions that can change the data in an object. You must be sure that they leave the object's data in a valid state. In "setter"s this means you must check the values of the parameters to see if they are valid before you do anything else. . 3.11 Software Engineering Case Study: Identifying the Classes in the ATM Requirements Specification When we think about how a program will be used, in terms that a user understands, we discover the names of many of the classes inside our software. Similar we can discover some of the methods (member functions) for these classes in scenarios describing what the user wants to do. .Close Prepare .Open Answered Questions . Is there a way to limit decimal places without using substrings The double length computations are always done to maximum accuracy. You can remove the decimal part of a double by assigning it to an integer. .As_is int rounded_down = unrounded; Thestandard technique for propper rounding to the nearest is to add 0.5 first .As_is int rounded = unrounded + 0.5; To round to, say two paces, you shift the decimal point before you round and then shift it back again: .As_is int rounded = (unrounded * 100.0)+0.5; .As_is double result = rounded / 100.0; For a running example, see .See ./rounding.cpp in this web site. Their are several more advanced techniques in C++. The `cmath` library has two or three helpfule function for rounding. I hope to cover these later. There are also some advanced nput/output `manipulator` functions for accurately formatting output to a specific number of places. This part of CS202 but here is a sample for formatting doolars and cents: .As_is #include .As_is . . . .As_is //Suitable for a check protected monetary field .As_is double dollars = 1234.45; .As_is cout << '$'; .As_is cout << setfill('*'); cout <