-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentSort.java
More file actions
55 lines (46 loc) · 2.01 KB
/
studentSort.java
File metadata and controls
55 lines (46 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*Deyora Perera
Course: ICS4U
Assignment: Sort and Search Assignment
Due date: April 6
Program Description: Using Binary Search and Insertion sort to create student database which can search students using key fields */
//imports
import javax.swing.JComboBox;
import javax.swing.JTextField;
//the "studentSort" class
public class studentSort {
protected String grade, name;//protect String grade,name, studentIDnorm variables
protected String studentIDnorm;
protected int studentIDInt;//protected int studentIDInt
//protected String studentIDString;
//constructor
public studentSort(JTextField nameField, JTextField studentIDField, JComboBox comboBoxGrade){
setName(nameField);//setting name
setID(studentIDField);//setting studentID
setGrade(comboBoxGrade);//setting grade
}//studentSort constructor
//overload constructor
public studentSort (String readName, int readID, String readGrade) {
name = readName;//name equals readName
studentIDInt = readID;//studentIDInt equals readID
grade = readGrade;//grade equals readGrade
}//overload constructor
public void setName(JTextField nameField) {//setter method for variable name
name = nameField.getText();//variable name is equal to text from nameField
}
public String getName() {//getter method for variable name
return name;//return name
}
public void setID(JTextField studentIDField) {//setter method for variable studentIDInt
studentIDnorm = studentIDField.getText();//studentIDnorm equals text from studentIDField
studentIDInt = Integer.parseInt(studentIDnorm);//studentIDInt equals parsed integer from studentIDnorm
}
public int getID() {//getter method for studentIDInt
return studentIDInt;//return studentIDInt
}
public void setGrade(JComboBox comboBoxGrade) {//setter method for variable grade
grade = (String) comboBoxGrade.getSelectedItem ();//grade equals selected item from comboBoxGrade
}
public String getGrade() {//getter method for grade
return grade;//return grade
}
}