Skip to content

Commit 9376e91

Browse files
committed
Classes pt 1 Excercise
1 parent 76cbaa4 commit 9376e91

4 files changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.ArrayList;
2+
3+
public class Course {
4+
private String courseName;
5+
private int courseId;
6+
private ArrayList<Student> enrolledStudents;
7+
8+
public String getCourseName() {
9+
return courseName;
10+
}
11+
public void setCourseName(String courseName) {
12+
this.courseName = courseName;
13+
}
14+
15+
public int getCourseId() {
16+
return courseId;
17+
}
18+
19+
public void setCourseId(int courseId) {
20+
this.courseId = courseId;
21+
}
22+
23+
public ArrayList<Student> getEnrolledStudents() {
24+
return enrolledStudents;
25+
}
26+
27+
public void setEnrolledStudents(ArrayList<Student> enrolledStudents) {
28+
this.enrolledStudents = enrolledStudents;
29+
}
30+
}

classes-part-one/exercises/src/main/java/Student.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,35 @@ public class Student {
77
// Drop your getters and setters below for the Student class.
88
// To instantiate the Student class, add your code to the main in the file, SchoolPractice.
99

10+
public String getName() {
11+
return name;
12+
}
13+
14+
public void setName(String name) {
15+
this.name = name;
16+
}
17+
18+
public int getStudentId() {
19+
return studentId;
20+
}
21+
22+
void setStudentId(int studentId) {
23+
this.studentId = studentId;
24+
}
25+
26+
public int getNumberOfCredits() {
27+
return numberOfCredits;
28+
}
29+
30+
public void setNumberOfCredits(int numberOfCredits) {
31+
this.numberOfCredits = numberOfCredits;
32+
}
33+
34+
public double getGpa() {
35+
return gpa;
36+
}
37+
38+
public void setGpa(double gpa) {
39+
this.gpa = gpa;
40+
}
1041
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
public class StudentPractice {
22
public static void main(String[] args){
33
//insantiate your Student class below
4+
Student quintonKornegay = new Student();
5+
quintonKornegay.setName("Quinton Kornegay");
6+
quintonKornegay.setNumberOfCredits(1);
7+
quintonKornegay.setGpa(4.0);
48
}
59
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
public class Teacher {
2+
private String firstName;
3+
private String lastName;
4+
private String subject;
5+
private int yearsTeaching;
6+
7+
public String getFirstName() {
8+
return firstName;
9+
}
10+
11+
public void setFirstName(String firstName) {
12+
this.firstName = firstName;
13+
}
14+
15+
public String getLastName() {
16+
return lastName;
17+
}
18+
19+
public void setLastName(String lastName) {
20+
this.lastName = lastName;
21+
}
22+
23+
public String getSubject() {
24+
return subject;
25+
}
26+
27+
public void setSubject(String subject) {
28+
this.subject = subject;
29+
}
30+
31+
public int getYearsTeaching() {
32+
return yearsTeaching;
33+
}
34+
35+
public void setYearsTeaching(int yearsTeaching) {
36+
this.yearsTeaching = yearsTeaching;
37+
}
38+
}
39+
40+

0 commit comments

Comments
 (0)