100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COS3711 EXAM PACK 2023

Rating
5,0
(1)
Sold
2
Pages
16
Grade
A+
Uploaded on
17-10-2023
Written in
2023/2024

COS3711 EXAM PACK 2023











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
October 17, 2023
Number of pages
16
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

COS3711
EXAM
PACK
2023
FOR AND QUERIES & EXAM HELP CONTACT:


,Exam 2009 Q & A
What we what to do with this thread is work through the 2009 Exam.

So I'll keep the thread up to date with everyone's help.
And please don't assume the answers are correct, I'm also a student..

1.1 Identify and motivate a design pattern that can be used to read such an XML
document and to create appropriate reward objects when the player wishes to continue the game.
[2]
Serializer pattern (to isolate the code to read from the file) followed by the AbstractFactory
pattern (to create the different types of objects) //See the post from rezrovs

1.2 Identify and motivate a design pattern that can be used to structure these three rewards
in a class hierarchy using the information given in the XML document. Draw a UML diagram
with appropriate
classes of this design pattern. [8]
Composite, because we're representing classes that are composed of other classes. Both Reward
and TreasureChest
look to be composite objects and Lamp, MagicMat and TreasureChest are components
See post from Kyle

2.1 Explain briefly the function of the FileVisitor and CodeVisitor classes which follow the
Visitor pattern.[2]
Given a path to a directory, FileVisitor traverses all the files and subdirectories in that path.
CodeVisitor open each file and searches for “#include” lines of text in each file.

2.2 Rewrite CodeVisitor so that the FileVisitor and CodeVisitor classes are completely
decoupled so that CodeVisitor can exist independently of FileVisitor. [5]
Language: C++
Class CodeVisitor: public QObject{
Q_OBJECT
public:
CodeVisitor(QString filter “-h”, bool recursive = true);
void getNumFiles() const;
QString getResultString() const;

public slots:
void processFile(QString filename);

private:
int m_NumFiles;
QStringList m_Result;
};

connect the FileVisitor signal to CodeVisitor slot
Language: C++ (QT)
[...]
FileVisitor fv(filter, recursive, symlink);
CodeVisitor cv(filter, recursive);

connect (fv, SIGNAL(foundFile(QString)), cv, SLOT(processFile(QString)));

[...]

, 2.3 State how the changes made in Question 2.2 would limit the features of the FileVisitor
and CodeVisitor classes.[2]
CodeVisitor is limited because with the changes the recursive directory visiting structure that
was inherited from FileVisitor is lost and therefore a CodeVisitor object can, at best, only visit
files in the working directory. Any recursive directory/file visiting will have to be re-
implemented in CodeVisitor.

FileVisitor is limited because the client code can only plug a FileVisitor object where it is
expected and not a derived subclass object through polymorphism, which would probably do
more that emitting a signal to indicate that a file has been found. In this particular case,
FileVisitor::processFile() does nothing special except emitting a signal whereas
CodeVisitor::processFile does something 'interesting'.

2.4 Once the FileVisitor and CodeVisitor classes are decoupled write the necessary code
to utilise these two classes to achieve a file processing task. [3]
Answer:

2.5 Using the decoupled FileVisitor and CodeVisitor classes implement the Strategy pattern
so that different file processing techniques can be included as different strategies. Rewrite
CodeVisitor to implement
the Strategy pattern. Include both header and cpp files.[5]
Answer:

2.6Using the solution given to Question 2.5 implement a concrete strategy to check if the file
names
end with a .txt extension. Include both header and cpp files.[5]
Answer:

3.1 Describe the relationship between a framework and an Application Programmers’
Interface (API)
referring to Qt4. [2]
A Framework is a large collection of general-purpose classes and conventions designed to
improve the consistency of
design. A Framework has a well-documented public Application Programmers’
Interface(API). An API is a description
of public functions, classes, and interfaces in a library.

3.2 One aspect of C++ that makes it very powerful is its ability to package code in several
different ways,
which Ezust refer to as containers of code. One example of such a container of code is a class
that is a collection of
functions and data members, and descriptions of its lifecycle management. Identify and describe
three other terms that are
used to describe containers of code. [6]
(p.171)
namespace – A collection of declarations and definitions, of classes, functions and static
members, perhaps spanning multiple files.
header file(.h) – Class definitions, template definitions, function declaration, inline definitions,
static object definitions.
source code module(.cpp) – Function definitions, static object definitions.
library(.lib) – An indexed collection of object file linked together.

Reviews from verified buyers

Showing all reviews
1 year ago

5,0

1 reviews

5
1
4
0
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

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.
examexpert01 Chamberlain College Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
195
Member since
2 year
Number of followers
111
Documents
937
Last sold
1 month ago

3,3

21 reviews

5
9
4
0
3
6
2
1
1
5

Recently viewed by you

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

Frequently asked questions