Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 30 pages
Exam (elaborations)

COS3711 Assigment 2 Year Module Due 2026

Document preview thumbnail
Preview 3 out of 30 pages

Comprehensive Study Material; Expert Verified & Exam-Ready This assignment package has been carefully developed to support serious academic preparation. Each solution is thoroughly researched, clearly explained, and backed by credible references giving you not just the answers, but a genuine understanding of the underlying concepts. The material is structured for clarity, making even complex topics approachable without sacrificing depth or accuracy. Whether you're consolidating your knowledge or preparing under time pressure, these resources are designed to help you walk into any exam with confidence.

Content preview

UNIVERSITY OF SOUTH AFRICA
College of Science, Engineering and Technology


⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄


COS3711: Advanced Programming

Assignment 2 — 2026

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄




COS3711
Module Code:
Advanced Programming
Module Name:
Assignment 2
Assignment:
2026
Year:




Submitted in partial fulfilment of the require-
ments for Advanced Programming — UNISA 2026

,UNISA | COS3711 Advanced Programming – Assignment 2



Question 1: Inheritance Hierarchy and Shape Drawing Application

Object-oriented design makes drawing applications considerably cleaner when shapes share
common properties. The Qt framework is well suited for this kind of work because its QPainter
API maps naturally onto pen-and-brush abstractions, and its widget system handles the ren-
dering surface (Stroustrup, 2013). The class hierarchy specified in the assignment separates
shared state from shape-specific measurements, which is exactly what abstract base classes
are for.


1.1 Design Overview


The hierarchy has three abstract layers and four concrete leaf classes. Shape holds pen width,
pen colour, and fill colour. Shape1Property extends Shape with one integer property (used
as radius for circles or side-length for squares). Shape2Property extends Shape1Property
with a second integer property (used for the second dimension of rectangles and ellipses).
The four concrete classes, Circle, Square, Ellipse, and Rectangle, each implement the pure
virtual draw() function. The UML diagram below captures this structure.

Shape
penWidth, penColour, fillColour
draw()




Shape1Property
property1
draw()




Shape2Property
property2
draw()




Circle Square
draw() draw()




Ellipse Rectangle
draw() draw()



Figure 1: UML inheritance hierarchy for the Shapes application



Page 2 of 30

, UNISA | COS3711 Advanced Programming – Assignment 2



1.2 Header Files


shape.h

1 # ifndef SHAPE_H
2 # define SHAPE_H
3


4 # include < QColor >
5 # include < QPainter >
6


7 class Shape {
8 public :
9 Shape () ;
10 Shape ( int penWidth , QColor penColour , QColor fillColour ) ;
11 virtual ~ Shape () {}
12


13 // Getters
14 int getPenWidth () const ;
15 QColor getPenColour () const ;
16 QColor getFillColour () const ;
17

18 // Setters
19 void setPenWidth ( int pw ) ;
20 void setPenColour ( QColor pc ) ;
21 void setFillColour ( QColor fc ) ;
22


23 virtual void draw ( QPainter & painter ) = 0;
24


25 protected :
26 int m_penWidth ;
27 QColor m_penColour ;
28 QColor m_fillColour ;
29 };
30


31 # endif // SHAPE_H




Page 3 of 30

Connected book
 image
W. Richard Stevens, Stephen A. Rago Advanced Programming in the UNIX Environment
Publisher: 2013 ISBN: 9780321637734 Edition: Unknown

Document information

Uploaded on
March 23, 2026
Number of pages
30
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
R80,74

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
BeeNotes
4,1
(40)
Sold
338
Followers
0
Items
981
Last sold
3 hours ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions