O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming Exercises

Exercises 2–4 build on the code of each previous exercise.

1:Write four classes called ElectronicDevice, Radio, Computer, and MobilePhone. Let ElectronicDevice be the base class for the other three classes and include the following three class members in its definition:
  • A private instance variable called brandName (of type string)

  • A public property called BrandName to access brandName

  • A private instance variable called isOn (of type bool)

Also include two methods called SwitchOn (which must write “On” and set isOn to true) and SwitchOff (which must write “Off” and set isOn to false). The three subclasses remain empty for now.

Write the appropriate code to test that even though the three subclasses have empty definitions, you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required