100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS3711 EXAM PACK 2023 $2.50   Add to cart

Exam (elaborations)

COS3711 EXAM PACK 2023

1 review
 28 views  2 purchases
  • Course
  • Institution

COS3711 EXAM PACK 2023

Preview 3 out of 16  pages

  • October 17, 2023
  • 16
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers

1  review

review-writer-avatar

By: sbmbopape • 1 month ago

avatar-seller
COS3711
EXAM
PACK
2023
FOR AND QUERIES & EXAM HELP CONTACT:
biwottcornelius@gmail.com

,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.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller examexpert01. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $2.50. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79373 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$2.50  2x  sold
  • (1)
  Add to cart