Object Orientation

Moderators: None (Apply to moderate this forum)
Number of threads: 46
Number of posts: 78

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Suggested oop design Posted by akkad on 4 Nov 2008 at 6:34 AM
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
{
  some members...
}

class AboutUs:WebPage    //a web page child
{
  some members...
}

class ContactUs:WebPage   //a web page child
{
  some members...
}

class startup
{
  main(argWebPageToOpen, argParentMember1,argSomeParentMember2)
  {
    WebPage webPage = new WebPage();
    webPage.Member1 = argSomeParentMember1
    webPage.Member2 = argSomeParentMember2

    if(argWebPageToOpen == AboutUs)
      new AboutUs()
    else if(argWebPageToOpen == ContactUs)
      new 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.
Thread Tree
akkad Suggested oop design on 4 Nov 2008 at 6:34 AM
Psightoplazm Re: Suggested oop design on 24 Apr 2009 at 9:12 PM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.