Jump to content

vigge

Members
  • Posts

    2
  • Joined

  • Last visited

    Never

About vigge

  • Birthday 01/21/1989

Contact Methods

  • MSN
    vigge19@gmail.com
  • Website URL
    http://vigge.net

Profile Information

  • Gender
    Male
  • Location
    Sweden

vigge's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm currently working class representations of some different filesystem objects. Currently I've got these pretty much done: class pFileSystemObject {} class pFolder extends pFileSystemObject {} class pFile extends pFileSystemObject {} class pImage extends pFile {} Anyway, whenever an instance of the pFile class is created, I'm planning on having the constructor check what the extension for the passed file is and then convert itself into for example a pImage instance if the extension is jpg/gif/png/etc. Is this possible in some simple way or will I have to create a new pImage instance inside the pFile class, re-set all the attributes for it and then destroy the pFile instance? Would I be doing this the wrong way? Should I check the extension before instancing the class and then create an instance of the appropiate one (I'm thinking this should be avoided since as much as the work of figuring out what type of file should be done inside the class itself)? Maybe using a Factory class would be the best choice? I'm having trouble deciding this alone as I've just started with OOP, so any advice on this would be great. Cheers
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.