Created
October 19, 2017 21:23
-
-
Save memish/4eea843b6ea54411e1d8a678056d98fd to your computer and use it in GitHub Desktop.
4 Files Listed Below
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
import java.util.Scanner; | |
//STARTER CLASS | |
public class StudentStarter | |
{ | |
public StudentStarter() | |
{ | |
Student s; | |
Scanner sc=new Scanner(System.in); | |
int currYear = 2018; | |
System.out.println("Enter your name."); | |
String name = sc.next(); | |
System.out.println("Enter your Graduation Year."); | |
int y = sc.nextInt(); | |
if((y - currYear) < 4){ | |
//upper school | |
s = new Upper(y, name); | |
}else{ | |
//middle school | |
s = new Middle(y, name); | |
} | |
System.out.println(s.chapelInfo()); | |
System.out.println(s.lunchInfo()); | |
} | |
} | |
//========================NEW CLASS BELOW============== | |
//STUDENT CLASS | |
public class Student | |
{ | |
int age; | |
String name; | |
int gYear; | |
public Student(int g, String name) | |
{ | |
gYear = g; | |
name = name; | |
} | |
public String chapelInfo(){ | |
return "You will have Chapel in the class of 44 Chapel"; | |
} | |
public String lunchInfo(){ | |
return "You will have lunch in the Tierney Dinning Hall"; | |
} | |
} | |
//========================NEW CLASS BELOW============== | |
//UPPER SCHOOL CLASS | |
public class Upper extends Student | |
{ | |
public Upper(int g, String name) | |
{ | |
super(g, name); | |
System.out.println("You are an Upper Schooler"); | |
} | |
public String chapelInfo(){ | |
super.chapelInfo(); | |
return "You will have chapel on Odd Days"; | |
} | |
public String lunchInfo(){ | |
return "You will have at 11am or 12:20pm"; | |
} | |
} | |
//========================NEW CLASS BELOW============== | |
//MIDDLE SCHOOL CLASS | |
public class Middle extends Student | |
{ | |
public Middle(int g, String name) | |
{ | |
super(g,name); | |
System.out.println("You are a Middle Schooler"); | |
} | |
public String chapelInfo(){ | |
super.chapelInfo(); | |
return "You will have Chapel on Even Days"; | |
} | |
public String lunchInfo(){ | |
return "You will have Lunch at 11:45"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment