using UnityEngine;
using System.Collections;
class Student {
public string Name;
public int[] Score = new int[3];
public Student(string name, int Score1, int Score2, int Score3){
Name = name;
Score[0] = Score1;
Score[1] = Score2;
Score[2] = Score3;
}
public int Total(){
return Score[0] + Score[1] + Score[2];
}
public int Avg(){
return Total () / 3;
}
public void ShowPrint(){
Debug.Log("Name=" +Name + " Total =" + Total() + " Avg=" + Avg());
}
}
public class hamStu : MonoBehaviour {
// Use this for initialization
void Start () {
Student[] student = new Student[3];
student[0] = new Student("ham", 100, 49, 29);
student[1] = new Student("ham1", 100, 49, 509);
student[2] = new Student("ham2", 100, 49, 29);
int max = int.MinValue;
Student maxStudent = null;
for( int i = 0; i < student.Length; i++)
{
if(max < student[i].Avg()){
max = student[i].Avg();
maxStudent = student[i];
}
}
print ("maxStudent");
maxStudent.ShowPrint();
}
// Update is called once per frame
void Update () {
}
}
