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
Exam (elaborations)

COS3711 Assigment 2 Year Module Due 2026

Rating
-
Sold
-
Pages
30
Grade
A+
Uploaded on
23-03-2026
Written in
2025/2026

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.

Show more Read less
Institution
Course

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

Written for

Institution
Course

Document information

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

Subjects

$4.91
Get access to the full document:

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


Also available in package deal

Get to know the seller

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 teachmetutor
Follow You need to be logged in order to follow users or courses
Sold
313
Member since
11 months
Number of followers
0
Documents
861
Last sold
1 week ago
BeeNotes

BeeNotes: Buzzing Brilliance for Your Studies Discover BeeNotes, where hard-working lecture notes fuel your academic success. Our clear, concise study materials simplify complex topics and help you ace exams. Join the hive and unlock your potential with BeeNotes today!

4.1

39 reviews

5
23
4
4
3
8
2
1
1
3

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card 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