Skill Building Exercises

 < Day Day Up > 



  1. Procure UML Design Tool: Procure a UML design tool. The features you’re looking for in addition to diagramming are reverse engineering and code generation. Many good shareware tools exist but it may be a good idea to download a commercial tool with a limited demo license.

  2. Obtain UML Reference: Procure a good UML reference and/or tutorial. Many good UML tutorials exist on the Internet so I recommend starting your search there. UML has evolved since it was first introduced so it is a good idea to get a recent reference.

  3. Simple Aggregate Class: Write a program that uses three simple classes named Whole, PartA, and PartB. Tailor the constructors and destructors of PartA and PartB to print out messages specific to those class types indicating their construction and destruction. In addition to a constructor and destructor provide one additional public interface function for each part class named showBehavior(). Tailor the behavior of the showBehavior() function to print out a different message to the screen for each part class. Create a simple aggregate version of Whole class where the Whole class has two private attributes; one of type pointer to PartA and the other of type pointer to PartB. Write a main() function to test your aggregate class. Create instances of PartA and PartB and test their interface functions. Then, using the code of example 12.12 as a guide, create an object of type Whole using the addresses of the part objects. Hint: The Whole class constructor should take two parameters: one that is a pointer to a PartA object and the other that is a pointer to a PartB object.

  4. Reverse Engineer: Use the UML design tool you procured in exercise 1 above to reverse engineer the code you wrote for Exercise 3.

  5. Composite Aggregate Class: Revise skill building exercise 3 to make the Whole class a composite aggregate. Leave the data members as pointer types but create each of the part objects in the Whole class constructor. Hint: Use the code in examples 12.6 and 12.7 as a guide.

  6. Composite Aggregate Class: Revise skill building exercise 3 again to make the Whole class a composite aggregate without using pointers.

  7. Simple/Composite Class: Revise skill building exercise 3 again to make the Whole class a combination simple and composite aggregation.

  8. Reverse Engineer: Use your UML tool to reverse engineer the code resulting from skill building exercise 7. How is it different from the diagram generated in skill building exercise 4?

  9. Design Simulation: Use your UML tool to design a simple simulation like the aircraft engine simulator from scratch. Perhaps a tank comprised of an engine and a gun. Both the engine and the gun are themselves comprised of several parts. Think of the interface the tank would need and how a message sent to a tank object would call a message on its engine object or gun object. When you think your design is complete generate the source code and study the results. Compare them to the aircraft engine simulation code. Evaluate the performance of your UML tool with regards to how close it comes to generating good header files and relatively complete class function implementation stubs. (see chapter 20)

  10. Implement Simulation: Write the code required to get the code generated in the previous exercise working.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net