Created
May 14, 2015 04:08
-
-
Save AnthonyLam/5469cb99c130e47ad678 to your computer and use it in GitHub Desktop.
Student
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
// How your professor is doing it. | |
public String student1 = "John Smith"; | |
public String student2 = "Zack Mills"; | |
public String student3 = "Fred Fonz"; | |
public int student1age = 20; | |
public int student2age = 21; | |
public int student3age = 44; | |
public void display (){ | |
if(student1age < student2age && student1age < student3age){ | |
System.out.println(student1 + " is the youngest of the three"); | |
} | |
else if(student2age < student1age && student2age < student3age){ | |
System.out.println(student2 + " is the youngest of the three"); | |
} | |
else{ | |
System.out.println(student3 + " is the youngest of the three"); | |
} | |
if(student1age > student2age && student1age > student3age){ | |
System.out.println(student1 + " is the oldest of the three"); | |
} | |
else if(student2age > student1age && student2age > student3age){ | |
System.out.println(student2 + " is the oldest of the three"); | |
} | |
else{ | |
System.out.println(student3 + " is the oldest of the three"); | |
} | |
} | |
/* How I would do it by the time I finish the course | |
public String studentName = "Anne Hathaway"; | |
public int studentAge = "30"; | |
public Student() { | |
} | |
public Student(String studentName,int studentAge){ | |
this.studentName = studentName; | |
this.studentAge = studentAge; | |
} | |
public Boolean isYoungerThan(Student student){ | |
return student.studentAge > studentAge; | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment