Need help with Factory Pattern -> previous exam Question. QTCreator

Ya, but the class needs to be written in full. ie it should be compiled without problems. Syntactical errors will cost you marks.

The factory method pattern's easy, isn't it? :) We only need to know 5 patterns for the exam: Factory Method, Singleton, MetaObject, Serializer and Memento.

Doesn't have to be compiled, can only give what is asked or relevant.

But yeah ShapeFactory(); should be in there.
 
Anyone did 4.8, the memento UML problem, what exactly would I want to save there?
Is my getState and setSate gonna return and accept a QStringList?

SAving the properties of Shape also doesn't looks as if it's gonna be straightforward. Since Shape2 has different properties.
 
Shape

#colour:QColor
#property1:int

+Shape()
+draw()
+setMememto(Mememto)
+createMememto():Mememto

//normal arrow down (uses)

Mememto

-state:QStringList

Mememto()
getState():QStringList
setState(QStringList)

That can't be 10 points, must be something else to it.
 
Anyone did 4.8, the memento UML problem, what exactly would I want to save there?
Is my getState and setSate gonna return and accept a QStringList?

SAving the properties of Shape also doesn't looks as if it's gonna be straightforward. Since Shape2 has different properties.

I think you need to make 2 Memento classes for each originator (ie. Shape and Shape2) since Shape2 has an additional data member.
 
I went with this in the end.


I think you need to make 2 Memento classes for each originator (ie. Shape and Shape2) since Shape2 has an additional data member.

Shape

#colour:QColor
#property1:int

+Shape()
+draw()
+setMememto(Mememto)
+createMememto():Mememto

Shape2

#property2:int

+Shape2()
+setMememto(Mememto)
+createMememto():Mememto

Mememto

-state:QStringList

-Mememto()
-getState():QStringList
-setState(QStringList)
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X