Announcements Last Post
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
May/Jun Exam Question 2
May 17, 2012 02:22PM
Holy Crap!

Please tell me that I wasn't the only one who could not wrap my head around this question.
I just could not understand how to apply the visitor pattern to the rate calculation for a booking...
Strategy Pattern maybe, but not the visitor pattern.

Anyone?
avatar Re: May/Jun Exam Question 2
May 17, 2012 02:36PM
Just tell yourself it went OK. Might as well. You can't fix it now. Me? I'm telling myself I klapped it. For a month I'll be happy as can be.

If you managed the others you'll be fine. It wasn't EASY. This course just never goes there. However it was about 100 000 000 times easiER than last year's. I'd say this time they at least provided a passable paper.
Re: May/Jun Exam Question 2
May 17, 2012 03:23PM
This is true.
Last years paper was a bit more difficult.
Re: May/Jun Exam Question 2
May 17, 2012 04:01PM
@Kendon, you are not alone on Q2 and I had no idea on Q6
hoping and praying the other 4 questions will give me a pass eye rolling smiley
Re: May/Jun Exam Question 2
May 17, 2012 04:36PM
Excellent paper. Well done to the Lecturer - this time around with the Videos created, paper being similar to Oct/Nov 2011 - we should pass if we studied well. Once again between work, home and my exams - my time management skills was a failure hence I must have failed again - entirely my fault this time. Best of luck for those of you that deserve to pass this course. I am done now - too old and tired of failing this course...sad smiley
Re: May/Jun Exam Question 2
May 17, 2012 05:22PM
I didn't have any problems with the visitor pattern.. Just look at this diagram.. the Booking is the Element (in the diagram) and Single/Double are concreteElements(in the diagram)
Just abstract the Visitor and make subclasses for each of the different rates. In each Visitor subclass you just
Language: C++ (QT)
void NonPremiumVisitor::visit(Booking* b) { b->SINGLEBPMMM = 0.75; b->DOUBLEBPMMM = 0.75; }
OR
Language: C++ (QT)
void PremiumVisitor::visit(Booking* b) { b->SINGLEBPMMM = 1.25; b->DOUBLEBPMMM = 1.10; }

A giveaway was that the SINGLEBPMMM and DOUBLEBPMMM were private. So we can change them in the derived classes.
and in the Booking base class (which I figured out in the exam that you only need it in the base class) you just

Language: C++ (QT)
void Booking::accept(Visitor* v) { v->visit(this); }
Sorry, only registered users may post in this forum.

Click here to login