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 () {
}
}
'Computer Language > 유니티' 카테고리의 다른 글
오버로딩. (0) | 2014.04.21 |
---|---|
goto문 2중 for문에서 합의하에 사용가능 (0) | 2014.04.21 |
String.Format 잘 봐두자 유용하게 쓰인다. (0) | 2014.04.21 |
포맷 형식 (0) | 2014.04.21 |
string 삭제 & 삽입 (0) | 2014.04.15 |