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 ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.