Programming in Any Language
Introduction to Classes
Click to enlarge
This first video will show you how and where to make your own classes. This section is the first of several that will show you how to make your own classes --- and, in turn, instantiate your own objects. PDFs: Slides, CoinToss1, CoinToss2, CoinToss2 Class
Properties
Click to enlarge
This video shows you how to set up properties and how to give access to programs that use these properties. You'll see the classic approach to setting up classes. You will also see shorthand versions using the get and set accessors. It is important you understand all the parts to classes before using the shorthand versions. PDFs: Slides, Form Code for Examples 1-6, Class EX1, Class EX2, Class EX3, Class EX4, Class EX5, Class EX6, Pet Form Code, Hobby Class, Pet Class, Animal Class.
Creating and Using a Class
Click to enlarge
In this video we create a class that has three properties. We then create a form that uses class by allowing the user to enter data into an object using the set accessors of the class. Then, using the get accessors of each property the entered data is displayed. PDFs: Slides, Class Code, Form Code.
Parameterized Constructors and Overloading
Click to enlarge
This video shows you how to set up a class to accept numeric data as either a double or a decimal. It also shows you how to set up multiple constructors so a program can pass data or nothing to the object. The reason for this is you want to be able to use your class in multiple programs. Those programs can be written with any data type without you needing to worry if the class can handle that. PDFs: Slides, Class Code, Form Code.
Storing Class Type Objects in an Array
Click to enlarge
You can create multiple occurrences of a class and store the resulting objects in an array. This gives you access to all the objects using a simple index. And that means you can step through an array of objects using a loop. Consequently, a banking application could be used to update the balance of thousands of customers. Likewise, we can use an array of objects to track the brand, model and price of many products we might be selling.
In this video we are using the espresso class we saw a few videos ago. But this time we are setting up an array to store many different espresso objects. And, because of the array, we have access to the brand, model and price of every espresso machine in our inventory.
You will learn that we can easily modify the espresso application we wrote previously allowing it to handle multiple objects.
PDFs: Slides, Class Code, Form Code.
Storing Class Type Objects in a List
Like the array, you can create multiple occurrences of a class and store the resulting objects in a list. And, again, via a simple index you can step through a list of objects using a loop.
We go a step further in this video by not limiting the list to a specific number of objects. This one is wide open. We can add as many objects as we wish. A Save button and a Load button were added to this example to show you how you can save your object data and later bring that data back to the list.
PDFs: Slides, Class Code, Form Code