Demo entry 6655580

py

   

Submitted by anonymous on Oct 27, 2017 at 05:58
Language: Java. Code size: 1.4 kB.

public class Pass {
	public static void main(String[] args) {
		School school = new School(600);
		Student student1 = new Student("小明", 1, 500, 98);
		Student student2 = new Student("大明", 2, 650, 90);
		Student student3 = new Student("老明", 3, 599, 90);
	    
		if(Status(school, student1)) {
			student1.getMessage();
			System.out.println("被录取");
		}
		if(Status(school, student2)) {
			student2.getMessage();
			System.out.println("被录取");
		}
		if(Status(school, student3)) {
			student3.getMessage();
			System.out.println("被录取");
		}
		
	}
	 static boolean Status(School school, Student student) {
		if(student.getTotal() > school.getLine() || 
		  (student.getSports() > 96 && student.getTotal() > 300))
			return true;
		return false;
	}
}

class School{
	private int line;
	
	public School(int line) {
		this.line = line;
	}
	public int getLine() {
		return line;
	}
	public void setLine(int line) {
		this.line = line;
	}
}

class Student{
	private String name;
	private int id;
	private int total;
	private int sports;
	
	public Student(String name, int id, int total, int sports) {
		this.name = name;
		this.id = id;
		this.total = total;
		this.sports = sports;
	}
	public int getTotal() {
		return total;
	}
	public int getSports() {
		return sports;
	}
	public void getMessage() {
		System.out.print(name + id);
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).