Last active
April 29, 2021 16:28
-
-
Save sezRR/3fb16fdb6f0fd8d0e07d8e88f8a9d2af to your computer and use it in GitHub Desktop.
Java Camp - Day 3 - Homework 2
This file contains 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 Instructor extends User { | |
private String biography; | |
private double averageRating; | |
public Instructor() { | |
} | |
public Instructor(int id, String firstName, String lastName, String email, int birthYear, String city, String biography, double averageRating) { | |
super(id, firstName, lastName, email, birthYear, city); | |
this.biography = biography; | |
this.averageRating = averageRating; | |
} | |
public String getBiography() { | |
return biography; | |
} | |
public void setBiography(String biography) { | |
this.biography = biography; | |
} | |
public double getAverageRating() { | |
return averageRating; | |
} | |
public void setAverageRating(double averageRating) { | |
this.averageRating = averageRating; | |
} | |
} |
This file contains 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 InstructorManager extends UserManager { | |
@Override | |
public void getAll() { | |
System.out.println("Instructors listed"); | |
} | |
@Override | |
public void getById(int instructorId) { | |
System.out.println("The instructor (have " + instructorId + "'s of id) listed"); | |
} | |
@Override | |
public void add(User instructor) { | |
System.out.println("Instructor ("+instructor.getFirstName()+") added"); | |
} | |
@Override | |
public void update(User instructor) { | |
System.out.println("Instructor ("+instructor.getFirstName()+") updated"); | |
} | |
@Override | |
public void delete(User instructor) { | |
System.out.println("Instructor ("+instructor.getFirstName()+") deleted"); | |
} | |
} |
This file contains 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 Main { | |
public static void main(String[] args) { | |
Student student1 = new Student(); | |
student1.setId(1); | |
student1.setFirstName("Sezer"); | |
student1.setLastName("Tetik"); | |
student1.setEmail("sezer@sezer.com"); | |
student1.setCity("Ankara"); | |
student1.setBirthYear(2005); | |
student1.setSchool("Example High School"); | |
student1.setGrade(10); | |
Student student2 = new Student(2, "Mehmet", "Erdemir", "mehmet@mehmet.com", 2005, "Denizli", "Example High School", 10); | |
StudentManager studentManager = new StudentManager(); | |
studentManager.getAll(); | |
studentManager.getById(1); | |
studentManager.add(student2); | |
studentManager.update(student1); | |
studentManager.delete(student1); | |
///////////////////////////////////////////////////////////////// | |
Instructor instructor1 = new Instructor(); | |
instructor1.setId(1); | |
instructor1.setFirstName("Engin"); | |
instructor1.setLastName("Demiroğ"); | |
instructor1.setEmail("engin@engin.com"); | |
instructor1.setCity("Ankara"); | |
instructor1.setAverageRating(94); | |
instructor1.setBiography("Microsoft Certified Trainer (MCT) ,PMP ve ITIL sertifikalarına sahibim."); | |
InstructorManager instructorManager = new InstructorManager(); | |
instructorManager.getAll(); | |
instructorManager.add(instructor1); | |
instructorManager.delete(instructor1); | |
} | |
} |
This file contains 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 extends User { | |
private String school; | |
private int grade; | |
public Student() { | |
} | |
public Student(int id, String firstName, String lastName, String email, int birthYear, String city, String school, int grade) { | |
super(id, firstName, lastName, email, birthYear, city); | |
this.school = school; | |
this.grade = grade; | |
} | |
public String getSchool() { | |
return school; | |
} | |
public void setSchool(String school) { | |
this.school = school; | |
} | |
public int getGrade() { | |
return grade; | |
} | |
public void setGrade(int grade) { | |
this.grade = grade; | |
} | |
} |
This file contains 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 StudentManager extends UserManager { | |
@Override | |
public void getAll() { | |
System.out.println("Students listed"); | |
} | |
@Override | |
public void getById(int studentId) { | |
System.out.println("The student (have " + studentId + "'s of id) listed"); | |
} | |
@Override | |
public void add(User student) { | |
System.out.println("Student ("+student.getFirstName()+") added"); | |
} | |
@Override | |
public void update(User student) { | |
System.out.println("Student ("+student.getFirstName()+") updated"); | |
} | |
@Override | |
public void delete(User student) { | |
System.out.println("Student ("+student.getFirstName()+") deleted"); | |
} | |
} |
This file contains 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 User { | |
private int id; | |
private String firstName; | |
private String lastName; | |
private String email; | |
private int birthYear; | |
private String city; | |
public User() { | |
} | |
public User(int id, String firstName, String lastName, String email, int birthYear, String city) { | |
this.id = id; | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.email = email; | |
this.birthYear = birthYear; | |
this.city = city; | |
} | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getFirstName() { | |
return firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
public String getEmail() { | |
return email; | |
} | |
public void setEmail(String email) { | |
this.email = email; | |
} | |
public String getCity() { | |
return city; | |
} | |
public void setCity(String city) { | |
this.city = city; | |
} | |
public int getBirthYear() { | |
return birthYear; | |
} | |
public void setBirthYear(int birthYear) { | |
this.birthYear = birthYear; | |
} | |
} |
This file contains 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 UserManager { | |
public void getAll() { | |
System.out.println("Users listed"); | |
} | |
public void getById(int userId) { | |
System.out.println("The user (have " + userId + "'s of id) listed"); | |
} | |
public void add(User user) { | |
System.out.println("User ("+user.getFirstName()+") added"); | |
} | |
public void update(User user) { | |
System.out.println("User ("+user.getFirstName()+") updated"); | |
} | |
public void delete(User user) { | |
System.out.println("User ("+user.getFirstName()+") deleted"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment