[Exercise 9] [Content] [Exercise 11]

Exercise 10


Task 10.1

Implement a class TCounter that realizes software counter with methods Increment(), Decrement(), Reset(), PreLoad(int x). Derive class TModCounter from TCounter. The TModCounter counts modulo n.

Solution:

Library:TCounter.h, TCounter.cpp
Application:counter.cbp, counter.cpp


Task 10.2

Implement an abstract class TFigure as a common ancestor of 2D-geometric figure. Derive two descendants - classes TCircle and TRectangle. Define pure virtual methods area() in TFigure and implement it in descendants. The methods returns area of the figure. Store count of control points and name of the figure in the common ancestor. Try behaviour of the code in the style of the program demonstrating automaton in the lecture.

Solution:

Library:TFigure.h, TFigure.cpp
Application:figures.cbp, figures.cpp


[Exercise 9] [Content] [Exercise 11]