package December_19th;
public class Teacher extends Person
{
private String subject;
public final void Explain()
{
System.out.println("Explanation begins");
}
}
package December_19th;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
boolean debug = false;
//Create a Person and make it say hello
Person myPerson = new Person();
myPerson.Greet();
/*Create a student, set his age to 21,
tell him to Greet and display his age*/
Student myStudent = new Student();
myStudent.SetAge(21);
myStudent.Greet();
myStudent.ShowAge();
/*Create a teacher, 30 years old,
*ask him to say hello and then explain*/
Teacher myTeacher = new Teacher();
myTeacher.SetAge(30);
myTeacher.Greet();
myTeacher.Explain();
if (debug)
{
new Scanner(System.in).nextLine();
}
}
}
package December_19th;
public class StudentextendsPerson
{
public final void ShowAge()
{
System.out.printf("My age is: %1$s years old" + "\r\n", age);
}
}
upackage December_19th;
private sing System;
public class Person
{
protected int age;
public final void Greet()
{
System.out.println("Hello");
}
public final void SetAge(int n)
{
age = n;
}
}