filmov
tv
10-2 C#:Creating Tape Class (Constructors, Object Instantiation, Inheritance, Properties)
![preview_player](https://i.ytimg.com/vi/bXHRKQIBTJw/maxresdefault.jpg)
Показать описание
C#: An Introduction to Object Oriented Programming
Programming Exercise 10-2: Creating Tape class
Create a class named Tape that includes fields for length and width in inches and properties for each field.
Also include ToString() method that returns a string constructed from the return value of the object's getType() method and the values of the length and width fields. Derive two subclasses - VideoTape and AdhesiveTape. The VideoTape class includes an integer field to hold playing time in minutes and a property for the field. The AdhesiveTape class includes an integer field that holds a stickiness factor - which is a value restricted to fall in the range of 1-10; and a property for the field.
Write a program that instantiates one object of each of the three classes, and demonstrate that all of each class's methods work correctly. Be sure to use valid and invalid values when testing the numbers you can use to set the AdhesiveTape class stickiness factor.
Learning to code? Follow my C# tutorials for beginners. I do a lot of C# programming challenges and C# projects as part of my homework - every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don't forget to subscribe, as I release new programming videos every day!
Programming Exercise 10-2: Creating Tape class
Create a class named Tape that includes fields for length and width in inches and properties for each field.
Also include ToString() method that returns a string constructed from the return value of the object's getType() method and the values of the length and width fields. Derive two subclasses - VideoTape and AdhesiveTape. The VideoTape class includes an integer field to hold playing time in minutes and a property for the field. The AdhesiveTape class includes an integer field that holds a stickiness factor - which is a value restricted to fall in the range of 1-10; and a property for the field.
Write a program that instantiates one object of each of the three classes, and demonstrate that all of each class's methods work correctly. Be sure to use valid and invalid values when testing the numbers you can use to set the AdhesiveTape class stickiness factor.
Learning to code? Follow my C# tutorials for beginners. I do a lot of C# programming challenges and C# projects as part of my homework - every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don't forget to subscribe, as I release new programming videos every day!