Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Belle-Star committed Sep 8, 2020
1 parent 5d879b0 commit 066dd07
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 12 deletions.
44 changes: 43 additions & 1 deletion src/main/java/com/github/perscholas/model/Course.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
package com.github.perscholas.model;

// TODO - Annotate and Implement respective interface and define behaviors
public class Course {
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Objects;

@Entity
public class Course implements CourseInterface {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private String instructor;

@Override
public Integer getId() {
return id;
}

@Override
public void setId(Integer id) {
this.id = id;
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

@Override
public String getInstructor() {
return instructor;
}

@Override
public void setInstructor(String instructor) {
this.instructor = instructor;
}
}
76 changes: 75 additions & 1 deletion src/main/java/com/github/perscholas/model/Student.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,79 @@
package com.github.perscholas.model;

// TODO - Annotate and Implement respective interface and define behaviors
public class Student {
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Entity
public class Student implements StudentInterface {

private String email;
private String name;
private String password;
private List<CourseInterface> studentCourses;

public Student() {
studentCourses = new ArrayList<>();
}

@Override
public String getEmail() {
return email;
}

@Override
public void setEmail(String email) {
this.email = email;
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

@Override
public String getPassword() {
return password;
}

@Override
public void setPassword(String password) {
this.password = password;
}

public List<CourseInterface> getStudentCourses() {
return studentCourses;
}

public void setStudentCourses(List<CourseInterface> studentCourses) {
this.studentCourses = studentCourses;
}

@Override
public String toString() {
return "Student{" +
"email='" + email + '\'' +
", name='" + name + '\'' +
", password='" + password + '\'' +
", studentCourses=" + studentCourses +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Student)) return false;
Student student = (Student) o;
return email.equals(student.email) &&
Objects.equals(name, student.name) &&
Objects.equals(password, student.password);
}
}
5 changes: 5 additions & 0 deletions src/main/resources/courses.create-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE Courses (
ID int NOT NULL PRIMARY KEY,
NAME varchar(50) NOT NULL,
INSTRUCTOR varchar(50) NOT NULL
);
20 changes: 10 additions & 10 deletions src/main/resources/courses.populate-table.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
insert into Course (id, name, instructor) values (1, 'English', 'Anderea Scamaden');
insert into Course (id, name, instructor) values (2, 'Mathematics', 'Eustace Niemetz');
insert into Course (id, name, instructor) values (3, 'Anatomy', 'Reynolds Pastor');
insert into Course (id, name, instructor) values (4, 'Organic Chemistry', 'Odessa Belcher');
insert into Course (id, name, instructor) values (5, 'Physics', 'Dani Swallow');
insert into Course (id, name, instructor) values (6, 'Digital Logic', 'Glenden Reilingen');
insert into Course (id, name, instructor) values (7, 'Object Oriented Programming','Giselle Ardy');
insert into Course (id, name, instructor) values (8, 'Data Structures', 'Carolan Stoller');
insert into Course (id, name, instructor) values (9, 'Politics', 'Carmita De Maine');
insert into Course (id, name, instructor) values (10, 'Art', 'Kingsly Doxsey');
insert into Courses (id, name, instructor) values (1, 'English', 'Anderea Scamaden');
insert into Courses (id, name, instructor) values (2, 'Mathematics', 'Eustace Niemetz');
insert into Courses (id, name, instructor) values (3, 'Anatomy', 'Reynolds Pastor');
insert into Courses (id, name, instructor) values (4, 'Organic Chemistry', 'Odessa Belcher');
insert into Courses (id, name, instructor) values (5, 'Physics', 'Dani Swallow');
insert into Courses (id, name, instructor) values (6, 'Digital Logic', 'Glenden Reilingen');
insert into Courses (id, name, instructor) values (7, 'Object Oriented Programming','Giselle Ardy');
insert into Courses (id, name, instructor) values (8, 'Data Structures', 'Carolan Stoller');
insert into Courses (id, name, instructor) values (9, 'Politics', 'Carmita De Maine');
insert into Courses (id, name, instructor) values (10, 'Art', 'Kingsly Doxsey');
5 changes: 5 additions & 0 deletions src/main/resources/students.create-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE Student (
Email varchar(50) NOT NULL PRIMARY KEY,
Name varchar(50) NOT NULL,
Password varchar(50) NOT NULL
);

0 comments on commit 066dd07

Please sign in to comment.