Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
i need ur suggestions building oop model for the following case:
- a parent class that represent a WebPage object. this class represent the common shared members between any web page.
- child classes that represent any web page (contact us, about us, ...), where the parent will be the common WebPage object above.
- a startup class that will start the application (say like the main method) and initialize the parent WebPage object.
the startup class will receive arguments, one of the argument will decide which web page(child) to open, other arguments will be used to assign some members in the parent class, to be more clear take a look at the following:
class WebPage //the parent
class AboutUs:WebPage //a web page child
class ContactUs:WebPage //a web page child
WebPage webPage = new WebPage();
webPage.Member1 = argSomeParentMember1
webPage.Member2 = argSomeParentMember2
if(argWebPageToOpen == AboutUs)
else if(argWebPageToOpen == ContactUs)
now the problem in the above code is that the children objects need to be inherited from a parent which has been initialized using outside arguments, where in the above example they didnt, so how to accomplish such design where the first solution flashed in my mind was to create initializer constructor for the child class that accept the arguments and then send it to its parent initializer constructor but i didnt like this solution, so any other ideas?? and plz if u need more clearer description ask me for it cuz am not sure if i have explain my problem well.