heyy, so i would like to verify about what i understands, so if let say i have class Car and 2 subclasses of it which is SuperCar and ClassicCar if i make a method to create those 2 subclasses within a CarFactory classes which letsay if in the MAIN i say CarFactory.make("super") it returns SuperCar and if i say CarFactory.make("classic") it return ClassicCar. this means i was making just a simple factory right?
if i want to make it into factory method i would need to make CarFactory an abstract / interface that has make() method . and then i should have other Factory such as DefaultCarFactory for example to create a default car and override the make() method
and ModifyCarFactory to create a modified car which also override the make() method and in this case this both 2 method still returning a type base on the parameter that i give whether it is "classic" or "super"
am i correct? :D
Aucun commentaire:
Enregistrer un commentaire