Description
1. Create a Student class, or reuse the Person class we made in class
a. With a name and age
2. Add a grade fieldmemberariable (that we can set a student’ s grade to a ‘C’) to the Student class
a. Make it private and add public properties so that we can set and get the grade
3. Write a method in our studentperson class to print to the screen the details in a studentperson instance (if we call that method it will Console.WriteLine() the student’s name, age, grade).
4. Use the Tester class that has a main to Create some students (or if you want to be brave create a Classroom class with an array of students)
a. set the student’s name
b. set student’s grade
c. The age
d. Print the student details using the method you wrote above (if you just try to Console.WriteLine the studentperson object you will print the class name)
5. Write an Address class that has 4 instance (non-static) String fieldsmemberariables: a. Street
b. City
c. State
d. Zip
6. Add a method called print to the Address class that will print out a nicely formatted address to the screen.
Try it out: Create several address instances and print them out
7. Make all the variables in Address class private (they are already that way by default) and provide appropriate properties to allow them to be obtained (get) and changed (set). Try it out: Use these properties showing that you can get and set the values.
8. Add an address to the Studentperson class. Make the address field private and add an appropriate property to access the address. Modify the Student print method to also print the address.
Hint: the way we would do this is just like you had in the student a String name; so, to you can have a variable/field Address addrs;
int age; string name;
Address addrs;
Hint 2: you need to instantiate the addrs object before you use it: Adress addrs = new Address(), otherwise addrs is null and any attempt to use it will result in a NullPointer exception. Hint 3: In the student’s print method from question 2, it would call on its address variable addrs.print()
Hint 4: nothing should be static in any of these classes, except for the method “Main”.
For fun (very optional) finish up the Bingo game, we will do this in the next class,
Create BingoPlayer, BingoManager & BingoCard classes
BingoCard has the multi-dimensional array, the method to populate and print that card
BingoPlayer has a string name and a BingoCard
BingoManager has an array of BingoPlayers, picks numbers, passes it to BingoPlayers, they check their cards, if they win, Bingo manager should announce winner’s name
Reviews
There are no reviews yet.