Example 30, 31, 32 - Point class with i) two instance variables x and y; ii) a ToString method returning x and y values as strings; iii) a constructor initializing x and y. In another class Class1, which includes the Main method, create an Point object and display it.
Example 33 - Add a property X to Point class which get and set the value for instance variable x. Test it in the Main method.
Example 34 - (by Zhihong) ParkingLot class which has i) two instance variables - totalSpaces and occupied; ii) a constructor initializing the two instance variables; iii) instance methods Enter, Leave, and IsFull.
Example 35 - Declare an integer array. Initialize the ith array element to be i. Print out array elements.
Example 36 - Declare and initialize an integer array. Compute the sum of array elements. Output their average value.
Example 37 - Show that an array index should be between 0 ~ array's Length -1. Otherwise there'll be IndexOutOfRange exceptions.
Example 38 , 38 continued - Reverse array elements by swapping.
Example 39 - Declare an array and initialize the elements with random integers generated by a Random object. Define a method PrintArray, which takes a string and an integer array as input and then display them.
Example 40 - Declare array of Point objects. First create the array and then create Point objects referred to by array elements. Define printPts method which takes a Point array and display it.
Example 41 - Define BankAccount class with i) instance variable balance; ii) a constructor for initialization; iii) a ToString method returning balance as an string; iv) a read-only property for balance. In another class with Main method, declare an array BankAccount objects, first create the array and then create BankAccount objects referred to by array elements. Output the individual balances and the total.
Example 42 , 42 continued - A more complete version of Point class. In another class including Main method, create an Point array and the Point objects referred to by array elements. Point objects are initialized with random double values. Change contents in these Point objects through properties. Define and call printPoints method to display Point arrays.
Example 43 - Two overloading CopyIt methods First copies from one single variable to another. Second copies from array to another. Test them in the Main method and display the results.
Example 44 - Final question in Project 5 (Text 5.23).