Edit again: I think I get it now. All I need to do then is use the current class colon the class I want to be able to access? Person : Student, or person : teacher Is that correct? Thank everyone for the help, I really appreciate it. This will help me learn what is OO and what is not. I really appreciate that.
I'm currently trying to learn the ins and outs of object oriented programming. Currently I have a new object that's something like the following:
class student
{
int grade; //0 - 100 as opposed to the characters A, B, C, etc.
string teacher; //For the teacher of the class the student is in.
}
class teacher
{
int courseAverage;
string name;
//teacher.name would correspond to the teacher in the student class.
}
class Program
{
student Jim;
Jim = new student();
teacher John;
John = new teacher();
}
static void grades()
{
Jim.grade = 100;
}
static void teacher()
{
Jim.teacher = "John Smith";
}
static void average()
{
int average; //For the sake of simplicity I'll leave the average at an int.
average = (Jim.grade + Sue.grade + Sally.grade + Robert.grade) / 4;
/*A loop would be set before the average variable to
ensure that only students of John would be counted in this.*/
}
static void teacheraverage()
{
John.courseAverage = average;//from the average method.
}
EDIT:
What I would like to do is modify the information from another class. However, I would like to modify the information from the Jim student in a method from within the program class. A method to compute the average of grades for the students who have the given teacher.
Also, the only reason I use static in these is because that is the only way I have managed to access variables across methods. I tried using static methods to use the methods across classes with no success. Is there another way to do this?
I would like to use the Jim student in multiple methods. One that will set Jim's grade, and another that will set the teacher. I would like to use different methods in this case so that I can learn how it is done.
Thank you in advance.
Okay, it looks like my understanding wasn't correct. I am going to try the methods within the class approach. Thank you all for the help.