Page 425 - IT2
P. 425

private int code;
                    private string type;
                    private int orientation;

                   public Camera()
                    {         }
                   public Camera(int code, string type, int orientation)
                   {
                       this.code = code;
                       this.type = type;
                       if (orientation >= 1 && orientation <= 4)
                           this.orientation = orientation;
                       else throw new Exception("valeur incorrecte");
                   }
                    public int Code
                    {
                        get { return code; }
                        set { code = value; }
                    }

                    public string Type
                    {
                        get { return type; }
                        set { type = value; }
                    }
                    public int Orientation
                    {
                        get { return orientation; }
                        set {
                            if (value >= 1 && value <= 4)
                                orientation = value;
                            else throw new Exception("valeur incorrecte");

                        }      }
                   public void tourner(int sens)
                   {
                       if (sens >= 1 && sens <= 4)
                             orientation = sens;
                         else throw new Exception("valeur incorrecte");
                   }
                   public virtual void afficher()
                   {
                        Console.WriteLine("La caméra {0} a l'orientation {1}",code,orientation);
                   }
                }
            -Questions  3)    4)  et   5) :

            Public class CameraMobile:Camera
                {
                    private int abs;
                    private int ord;
                    public CameraMobile():base()
                    {         }
                    public CameraMobile(int code, string type, int orientation,int abs,int ord)
                        :base(code,type,orientation)
                    {
                        this.abs = abs;

                                          www.itlearning-settat.com

                                   Email: admission@itlearning-settat.com

                                                   Tél.:0661077812
   420   421   422   423   424   425   426   427   428   429   430