Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Date;
- public class RunWeek5 {
- public static void main(String[] args) {
- Student s1 = new Student("Shamil", "Arslanov", Date.valueOf("2000-02-17"));
- Student s2 = new Student("Marya", "Sayanova", Date.valueOf("2001-07-01"));
- Student_Girl g1 = new Student_Girl("Masha", "Xyz", Date.valueOf("1999-06-06"), true, true);
- Group data = new Group();
- data.addStudent(s2);
- data.addStudent(s1);
- data.addStudent(g1);
- }
- }
- public class Person {
- protected String firstName;
- protected String lastName;
- private static int ID = 1;
- protected int personId;
- public Person(String firstName, String lastName) {
- this.firstName = firstName;
- this.lastName = lastName;
- ++ID;
- this.personId = ID;
- }
- public Person() {
- this.firstName = "Null";
- this.lastName = "Null";
- this.personId = ++ID;
- }
- public String getFullName() {
- return firstName + " " + lastName;
- }
- public String getFullName(boolean reverse) {
- if (reverse) return lastName + " " + firstName;
- else return getFullName();
- }
- @Override
- public String toString() {
- return "Person{" +
- "firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", personId=" + personId +
- '}';
- }
- }
- import java.sql.Date;
- public class Student extends Person {
- private Date dateOfBirth;
- public Student(String firstName, String lastName, Date dateOfBirth) {
- super(firstName, lastName);
- this.dateOfBirth = dateOfBirth;
- }
- @Override
- public String toString() {
- return "Student{" +
- "dateOfBirth=" + dateOfBirth +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", personId=" + personId +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement