본문 바로가기
Class/220728

Class(2-2)

by pms93 2022. 7. 28.
package constructor;

public class Student {

	private String name;
	private int kor, eng, mat, total;
	private double avg;
	
	public Student(String name, int kor, int eng, int mat) {
		this.name = name;
		this.kor = kor;
		this.eng = eng;
		this.mat = mat;
	}
	
	public String getName() {
		return name;
	}

	public int getKor() {
		return kor;
	}

	public int getTotal() {
		setTotal();
		return total;
	}
	private void setTotal() {
		this.total = this.kor + this.mat + this.eng;
	}
	public double getAvg() {
		return getTotal() / 3.0;
	}

	public int getEng() {
		return eng;
	}

	public int getMat() {
		return mat;
	}

	
}

'Class > 220728' 카테고리의 다른 글

Class_Overload(1-2)  (0) 2022.07.28
Class_Overload(1-1)  (0) 2022.07.28
Class(2-1)  (0) 2022.07.28
Class(1-2)  (0) 2022.07.28
Class(1-1)  (0) 2022.07.28