forked from nus-cs2113-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from yeekian/master
Add and Delete Students from StudentList
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class Student { | ||
private String matricNumber; | ||
private double GPA; | ||
|
||
public Student(String matricNumber) { | ||
this.matricNumber = matricNumber; | ||
this.GPA = 0.0; | ||
} | ||
|
||
public String getMatricNumber() { | ||
return matricNumber; | ||
} | ||
|
||
public double getGPA() { | ||
return GPA; | ||
} | ||
|
||
public void setMatricNumber(String matricNumber) { | ||
this.matricNumber = matricNumber; | ||
} | ||
|
||
public void setGPA(double GPA) { | ||
this.GPA = GPA; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class StudentList { | ||
private Integer numberOfStudents; | ||
private Student[] studentList = new Student[0]; | ||
ArrayList<Student> studentArrayList = new ArrayList<>(Arrays.asList(studentList)); | ||
|
||
public StudentList() { | ||
this.numberOfStudents = 0; | ||
} | ||
|
||
public void deleteStudent(Student student){ | ||
studentArrayList.remove(student); | ||
} | ||
|
||
public void addStudent(Student student){ | ||
studentArrayList.add(student); | ||
} | ||
} |