Introduction to OOP Chapter 7: A Billiards Game: next previous audio real text

Graphical Objects can Draw themselves


procedure TWall.draw(canvas: TCanvas);
begin
        with canvas do begin
                Brush.Style := bsSolid;
                Brush.Color := clBlack;
                fillRect(Rect(x, y, x + width, y + height));
        end;
end;

procedure THole.draw(canvas : TCanvas);
begin
        with canvas do begin
                Brush.Style := bsSolid;
                Brush.Color := clBlack;
                Ellipse(x-5, y-5, x+5, y+5);
        end;
end;

Intro OOP, Chapter 7, Slide 5