dimanche 2 août 2015

how to design program using polymorphism [on hold]

have a watch with 4 buttons. one button is for switching between modes rest 3 buttons working depends on the current mode given by first button.

//i think about design looks like this.
    class watch{
    //method for change the mode
    enum mode{Timer,Light,digital-clock}        
    changeMode()...
    //three methods for each derived class
    virtual A(),virtual B(),virtual C()...
    }

    class Timer:watch{
    override A(),override B(), override C()
    }

    class Light:watch{
    override A(),override B(), override C()
    }

    class digital-clock:watch{
    override A(),override B(), override C()
    }

Aucun commentaire:

Enregistrer un commentaire