Welcome! Log In Create A New Profile


Oct/Nov 2011 paper

Posted by Vampyre 
Announcements Last Post
Announcement : Programming Students at UNISA School of Computing 06/19/2019 02:01PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Oct/Nov 2011 paper
May 01, 2012 11:58AM
ok so this is my attempt at Q1) please comment

Language: C++ (QT)
class Foo :public QObject{ Q_OBJECT public: Foo(int i); void decrement(int i); void increment(int i); signal: void changeVal(int i, Qstring changeType); private: int x; }   foo.cpp void Foo::decrement(int i){ x =x+i; emit changeVal(x,"dec"); } void Foo:increment(int i) { x = x-i; emit changeVal(x,"inc"); }     class FooDisplay:public QObject{ Q_OBJECT public: FooDisplay(); slots: void showChange(int i, QString chageType); private: int x;   FooDisplay.cpp ... void FooDisplay::showChange(int i, QString changeType) { if (changeType=="inc") cout << "Incrmenting x "<<i<<"\n"; if (changeType=="dec") cout << "Decrementing x "<<i<<"\n"; } ...

Language: C++ (QT)
Foo f; FooDisplay fd; connect(&f,SIGNAL(changeVal(int,QString)),&fb,SLOT(showChange(int,QString); f.incrment(10); f.decremet(5);

in FooDisplay.h Change and remove showChange implementation from the cpp
Language: C++ (QT)
virtual void showChange(int i,QString outType)=0;

Language: C++ (QT)
class OutConsole:public FooDisplay { public: OutConsole() {} void showChange(int i, QSTring changeType) { QTextStream cout(stdout); //send it to console with this concrete class if (changeType=="inc") cout << "Incrmenting x "<<i<<"\n"; if (changeType=="dec") cout << "Decrementing x "<<i<<"\n"; } }   class OutFile:public FooDisplay { void showChange(int i, QSTring changeType) { QFile f("random.txt") f.open(QFile::writeonly); QTextStream fout(&f); //send it to file with this concrete class   if (changeType=="inc") fout << "Incrmenting x "<<i<<"\n"; if (changeType=="dec") fout << "Decrementing x "<<i<<"\n"; f.close(); }   }

Language: C++ (QT)
FooDisplay* foodistCon = new OutConsole(); // stratergy Console FooDisplay* foodistFile = new OutFile(); // stratergy File Foo f; connnect(&f,SIGNAL(changeValue(int,QString),foodistCon(int,Qstring)); connnect(&f,SIGNAL(changeValue(int,QString),foodistFile(int,Qstring));
Re: Oct/Nov 2011 paper
May 01, 2012 11:59AM
Question 2.2 any one with any ideas here im stuck here for now :-(
avatar Re: Oct/Nov 2011 paper
May 01, 2012 02:13PM
Just off the cuff, you could probably use one function for both incrementing and decrementing (since decrementing is really just incrementing negative numbers). I haven't looked at the question (that's on the other computer), so I might be wrong, but the idea of creating a special function for the opposite sign just goes against my grain, so there's my piecemeal tuppence worth. I'll fire it up a bit later and try to have something more substantial to say.
Re: Oct/Nov 2011 paper
May 02, 2012 08:38PM
i think the question gave the functions need to double check, but i sent it to the lect and he gave the solution 86/100, marks lost for not Inheriting on QObject , and some syntax error which i fixed before posting.
avatar Re: Oct/Nov 2011 paper
May 03, 2012 05:16PM
So my tuppence worth was worth only a ha'penny, then. smile

Looks like you're on the right track. Sorry, I still haven't got back to this one, so I don't have anything to offer for that other question.
Re: Oct/Nov 2011 paper
May 13, 2012 04:38PM
@Vampyre - Thanks for starting this post. I'll try to contribute, but after doing all the prev exams I'm feeling pretty useless :-(

2.2 also bowled me, thus I can only start at 2.5...

2.5.1) Indent was not specified
x.objectToXml(b, 0);
And I found alot of "t" defined in the same class...this could also cause the compile error...
2.5.2) <object class="ABCExt"name="b">
<property name="n" type="int" value="2">
2.5.3) The class doesn't allow multiple instances to share the same state.
2.5.4) It only writes.
2.5.5a) foreach(ABCExt x in list)

any feedback will be really appreciated!
Re: Oct/Nov 2011 paper
May 13, 2012 04:45PM
Question 4
4.1 a) CATe
b) _

4.2 a) Starting and controlling other processes.
b) When data is availible on the selected channel of the child process.
c) connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(logOutput()));

I just have to add... this question is so stupid... If this was a course for people that want to write programs for Nokia using QT...then 4.2 was in line. I think its very unreasonable to ask questions so deliberately focused on QT. We want to learn about Advance Programming, not developing mobile applications. AND I think its safe to say that 98% of the students will never open QT again after this course.
*SIGH* but now I feel better.
I really feel for you guys that wrote this exam... and I really hope that the Lecturer will ask relevant questions this time round.
Re: Oct/Nov 2011 paper
May 14, 2012 07:27PM
QT is a hugely popular C++ framework. It rivals the Boost framework for C++. What you're learning here is, in my books, Advanced Programming. Reflection (which cannot be done without meta objects and special compilation in regular C++) Multithreading (not available in standard C++) and Design Patterns make solutions for problems which you will encounter frequently in the real world. These programs don't really have anything to do with Mobile development.

Sorry, I haven't read the paper yet or anything so if I'm off base or hit a nerve I apologize.
Re: Oct/Nov 2011 paper
May 14, 2012 07:34PM
this is what i got for Q2 , lol my 1st attempt was totally wronge but the lecturer guided me

Q_PROPERTY , provides a facility which gives a different ways to access
datamembers, either directly via setters/getters or indirectly via the
MOC/QMetaobject interface,
Q_ENUMS ,is a special macro to generate string-to-enum conversion functions also
part of the QMetaobject/QObject.

2.1 - this is from last years assignment
Language: C++ (QT)
//.h class ABCEx::public Qobject, public ABC { Q_OBJECT public: Q_PROPERTY(int n READ getT write setT); Q_PROPERTY(QString ty READ getType WRITE setType); ABCExt(types t,int i) ; int getT(); Qstring getType(); void setType(Types t); }     //.cpp ABCExt::ABCExt(types t, int i)::ABC(t,i){} int ABCExt::getT(){ return t; } QString ABCExt::getType(){ QString tp = ABC::m_types.at(m_type); return tp; } void ABCExt::setType(QString tp) { m_type = ABC::Types(ABC::m_types.indexOf(tp)); }

2.3) *marked correct by Lecturer*
beacuse the base class ABC is not derived from QObject , therefore a->metobject
would fail because there is no Metadata been generated for it by MOC.

Language: C++ (QT)
ABCExt *a = new ABCExt(ABC::Types(2),2);

Language: C++ (QT)
x.onjectToXml(QObject , Int) the function parameter is missing an integer for indentspace,

Language: C++ (QT)
2.5.2) <object class="ABCExt" name=""> <property name="n" type="int" value="2"/> <property name="ty" type="types" value="C"/> </object>
According to the lecturer. The answer lays in last years 201 tut letter. and from what i read into its got somethign to do with
the momento has 2 conditions, 1) to save it internal state and 2) to be self aware that it can save it state.
So this object can save it state but is not self aware of the ability (what ever that means) to save it state.

2.5.4 *again here not 100% sure but the lectures feedback was along these lines*
The serliazer class is can save its state or objects and has no awareness that they are being seriolised.Any Qobject can be serialised with the XMLExport , therefore it impliments the serialiser pattern.

Language: C++ (QT)
QTextStream cout(stdio); foreach (ABCExt* x,list) cout << x.objectToXml();

Language: C++ (QT)
b->setParent(a); c->setPatrent(a);
Re: Oct/Nov 2011 paper
May 14, 2012 07:41PM

lol I was suckered into doing QT/C++ ( i did java year 1/2) which changed to QT. i didnt really want to do any programming as an aoptional subject but a bad subject choice is 1st year has forced me to take this.

I must say i work on both Linux and Windows and QT is VERY relavent esp in the linux with gui development. when u actually think about its quite a versitile framework. but 3month in a semester is just nuts! this should really be a year module which gives time to explore the framework properly.

Allot of concepts in here also follow in the operating system design subject also , threading , processes , mutex , sempahore etc.. are all concepts used widely.

ok let me get back to the books im not feeling confident at all about this subject. sad smiley
Re: Oct/Nov 2011 paper
May 15, 2012 11:31AM
can somebody pls send me this module"s study material, im writing re-exam on kholoboledi@gmail.com
Re: Oct/Nov 2011 paper
May 15, 2012 01:23PM
you are helpful thanks
and everyone who is contributing thanks
im in JHB now but from tommor i will be in PTA
do you guys have study group in PTA
pls i want to join
Re: Oct/Nov 2011 paper
May 16, 2012 01:44AM

Your 2.5.1 is wrong.. If it was correct then your 2.5.2 would be wrong. The default parameter is supplied for XMLExporteye popping smileybjectToXML second parameter so not putting it in would just mean it would use the default (which is 0).. The object is of type ABC and ABC does not inherit from QObject, so is not of type QObject and therefore does not have a QMetaObject data member.

The class ABC is not a QObject and the XMLExporteye popping smileybjectToXML function takes, as its first parameter, a pointer to a QObject.
Re: Oct/Nov 2011 paper
May 16, 2012 09:48AM
Yep I see your point , wat u said was my 1st answer and still thing it makes more sence

,before I sent to the lecturer for marking , the marking coment on the question came back was with " look closer at the parameter list is something missing ?" i assumed it was the missiong parrm.... lol I hate the cryptic comments where u need to assume wats correct sad smiley

I just had a look at the question again and "that something missing could be Qobject inheritance *sigh* I think I'm gonna stick to my original ans and what u said sad smiley don't have time now to decrypt lectures riddles .
Re: Oct/Nov 2011 paper
May 16, 2012 11:59AM
Hey guys,

I will try and attempt my opinion on Question 5

5.1 Basic UML diagram of the examples we have seen in this course. I would say the one difference is that instead of two derived classes we will now have 4 with 'DataDiplayer' as the base class.
Concerning the key functions: I would make the display() in the base class virtual so that the derived classes can inherit.
The Abstract factory with a virtual create() function as the base class. Then the Factory class with the create function that receives the type of display that needs to be created. The create function will then create the appropriate display class.

5.2 (1) It solves this by the client now calling the factory classes and does no longer have any display class objects. Therefor cannot create them.
(2) When the factory class is called a pointer to the appropriate display class is returned. So the client does not need to change between which class it wants to use, this is based on whatever is returned. (not sure about my wording of this one.)
(3) Client doesn't need to change any code if we pass some sort of argument or user defined variable to the factory class. Only a new derived class to the display class needs to be created, and we then just pass the correct name through to create the new display object.

This is basically how i see it.
Re: Oct/Nov 2011 paper
May 16, 2012 01:58PM

Regarding your answer of 2.5.1 i have two concerns which might be what the lecturer was referring to:
1 - As dubbelodub mentioned about the parameter 'b' in the question can't be passed in as it is not a QObject.
2 - The function objectToXml returns a QString. In the question code as well as your answer code it is not set to a QString variable. Think this might be another reason it will fail.
should look something like this: QString str = x.objectToXml(b);

Any opinions on this?
Re: Oct/Nov 2011 paper
May 16, 2012 05:11PM
@RBester101 Yes, your number '2'... I think it doesn't matter if the return type is returned into a variable or not.. I think it will just be discarded (with a warning at most from the compiler) if no variable to return into is given..

I'm 99% sure number '1' is correct.. The question about whether or not the function signature matches the invocation signature seems a bit too easy in my opinion and
doesn't really have much to do with QT or design patterns at all.

Re: Oct/Nov 2011 paper
May 16, 2012 06:49PM
Well, I hope that everyone gets a good nights rest to be ready for tomoz.
Have a good one!
Re: Oct/Nov 2011 paper
May 16, 2012 06:56PM
Yeah with this im going with the qobject answer it makes more since every time I read it

Your no 5 seems spot on make sure u use the correct symbols on the uml my model answer had the wronge diamond and marks where deducted
Re: Oct/Nov 2011 paper
May 16, 2012 07:26PM
Cool man.

The more I study the less it seems I know. :s

Good luck for tomorrow.
Re: Oct/Nov 2011 paper
May 16, 2012 07:31PM
Good luck friends.. lets return here tomorrow
Re: Oct/Nov 2011 paper
May 16, 2012 11:06PM
Good luck peeps ... lets hope unisa has mercy on us!
Re: Oct/Nov 2011 paper
May 17, 2012 01:54PM
So how's everybody feeling?

Who was the guy in Heathfield with me? ...Sorry I didn't say cheers, I'm kinda Zonked after that :/

I think it went rather well though for me even though I didn't manage to finish the last point question of number 5.
Re: Oct/Nov 2011 paper
May 17, 2012 02:06PM
I'm feeling somewhere in between. Not good and not bad either.

I was stumped with the UML of the visitor. But I think the other questions werent so bad. I managed to complete everything though.
Re: Oct/Nov 2011 paper
May 17, 2012 02:57PM

Yes, I think I the don't explain it well in the book at all.. The only reason I remembered it was because of this diagram Visitor_Pattern
Re: Oct/Nov 2011 paper
May 17, 2012 06:42PM
Yeah, I'm with RBester... A little more to the bad side, but well...can't do anything about it now...
I've got another 2, then I can rest and wait for results...

Have a good one peeps

smileys with beer
Re: Oct/Nov 2011 paper
May 21, 2012 12:51PM
it was erm .. yeah ... im not really sure about this one

for some odd reason, and after reading one of the tut letters which mentioned that GOF dont explain the visitor and that other schools of thought argued the patteren actually breaks the problems it tries to solve and is not really used much ... i decided to give it a skip ... and hence my epic FAIL!

i kinda remember seeing a UML before, so i know my diagram is ok .. just not sure on the functions and datat members :-(

ahh well we will see ... the vew MVC questions nailed me.. i completely left that out as well.

cross fingers...
Re: Oct/Nov 2011 paper
June 04, 2012 01:36PM
I think this May? June 2012 was one of the best papers i have seen at Unisa.
Hoping to see u at graduation.
Sorry, only registered users may post in this forum.

Click here to login