Skip to content

Commit

Permalink
Updated software
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanashastri committed Jun 14, 2017
1 parent d5d35de commit 3844678
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 53 deletions.
10 changes: 8 additions & 2 deletions src/JavaFXGUI/EnterInfoTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public EnterInfoTab(MenuTabPane par, EnterStudentTab prev, String title,
while(file.hasNext()){
if(goingIn){
stringData = file.nextLine();
System.out.println(stringData+ ", " + v + ", " + version);

if (stringData.equals("+++")){
v++;
}
Expand Down Expand Up @@ -199,6 +197,8 @@ public void addData(ArrayList<String> option){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,TIME,REASON");
TimeComparator c = new TimeComparator();
data.get("in").getStudentList().sort(c);
for(Student st : data.get("in").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand All @@ -225,6 +225,8 @@ public void addData(ArrayList<String> option){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,REASON,EXCUSED,TIME,ARRTIME");
TimeComparator c = new TimeComparator();
data.get("outin").getStudentList().sort(c);
for(Student st : data.get("outin").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand Down Expand Up @@ -266,6 +268,8 @@ public void addData(ArrayList<String> option){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,TIME,REASON");
TimeComparator c = new TimeComparator();
data.get("in").getStudentList().sort(c);
for(Student st : data.get("in").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand All @@ -292,6 +296,8 @@ public void addData(ArrayList<String> option){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,REASON,EXCUSED,TIME,ARRTIME");
TimeComparator c = new TimeComparator();
data.get("outin").getStudentList().sort(c);
for(Student st : data.get("outin").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand Down
14 changes: 10 additions & 4 deletions src/JavaFXGUI/EnterStudentTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ private void submitButton(){
}
}
}




}

else{
Expand All @@ -283,10 +279,17 @@ private void moveOn(boolean signIn, Student student){
EnterInfoTab tab3;
boolean outin = false;
int j = 0;
for(int i = 0;i<data.get("outin").getOutInList().size();i++){
System.out.println("outin: "+ data.get("outin").getOutInList().get(i));
}
for (int i =0; i < data.get("outin").getStudentList().size(); i++){
System.out.println(data.get("outin").getStudentList().get(i));

if (student.equals(data.get("outin").getStudentList().get(i))){
if(!data.get("outin").getOutInList().contains(student)){
j = i;
outin=true;
}
}
}

Expand All @@ -296,6 +299,7 @@ private void moveOn(boolean signIn, Student student){
String time = formatter.format(todayTime);

data.get("outin").getStudentList().get(j).setArrTime(time);
System.out.println(data.get("outin").getStudentList().get(j).getArrTime());

LocalDate todayDate = LocalDate.now();
String date = todayDate.toString();
Expand All @@ -309,6 +313,8 @@ private void moveOn(boolean signIn, Student student){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,REASON,EXCUSED,TIME,ARRTIME");
TimeComparator c = new TimeComparator();
data.get("outin").getStudentList().sort(c);
for(Student st : data.get("outin").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand Down
9 changes: 8 additions & 1 deletion src/JavaFXGUI/OptionSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class OptionSelect extends VBox{
private Label titleLabel;
private int height, width;
private HBox bottomHBox;
private Label pageNumberLabel;
private Button submitButton;
private EnterInfoTab tabToBeClosed;
private Student student;
Expand Down Expand Up @@ -93,6 +92,7 @@ public void init(){
submitButton = new Button("Submit");
submitButton.setAlignment(Pos.BOTTOM_CENTER);
submitButton.getStyleClass().add("submitButton");
submitButton.setMaxSize(100, 4);
submitButton.requestFocus();
submitButton.setDefaultButton(true);
submitButton.setOnAction(e -> handle());
Expand All @@ -112,6 +112,7 @@ public void init(){

bottomHBox = new HBox();
bottomHBox.getStyleClass().add("bottomHBox");
bottomHBox.setFillHeight(false);
getChildren().add(bottomHBox);

}
Expand Down Expand Up @@ -215,7 +216,12 @@ public void splitScreen(int page, ArrayList<String> data){
OptionButton opt = new OptionButton(data.get(i), data.get(i), page);
left.add(opt);
}

buttonList.get(page).addAll(left) ;
buttonList.get(page).get(0).getStyleClass().add("optionButton-top");
buttonList.get(page).get(1).getStyleClass().add("optionButton-mid");
buttonList.get(page).get(2).getStyleClass().add("optionButton-bottom");

option.add("");

updateState(0);
Expand Down Expand Up @@ -243,6 +249,7 @@ public void addRadButton(){
});

HBox hb = new HBox(60);
hb.getStyleClass().add("hbox");
hb.getChildren().addAll(l,h,p);
hb.setAlignment(Pos.CENTER);

Expand Down
5 changes: 4 additions & 1 deletion src/JavaFXGUI/SettingHBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public SettingHBox(StartApplication p, double width,

TabPane tableTabPane = new TabPane();
tableTabPane.setSide(Side.LEFT);
tableTabPane.getStyleClass().add("tabTable");
tableTabPane.getStyleClass().add("tab");

tableSignIn = createTableIn();

Expand Down Expand Up @@ -317,6 +317,8 @@ private void saveFile(){
}
writer.println();
ArrayList<Student> temp = data.get("in").getStudentList();
TimeComparator c = new TimeComparator();
temp.sort(c);
for (int i = 0; i < temp.size(); i++){
writer.print (temp.get(i).getDate() + ", ");
writer.print (temp.get(i).getName() + ", ");
Expand All @@ -342,6 +344,7 @@ private void saveFile(){
}
writerOutIn.println();
temp = data.get("outIn").getStudentList();
data.get("outIn").getStudentList().sort(c);
for (int i = 0; i < temp.size(); i++){
writerOutIn.print (temp.get(i).getDate() + ", ");
writerOutIn.print (temp.get(i).getName() + ", ");
Expand Down
10 changes: 6 additions & 4 deletions src/JavaFXGUI/StartApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,23 @@ public void start(Stage primaryStage) throws Exception {
borderPane.prefHeightProperty().bind(scene.heightProperty());
borderPane.prefWidthProperty().bind(scene.widthProperty());

content.getStyleClass().add("background");
borderPane.getStyleClass().add("background");

borderPane.setCenter(tabPane);
content.getChildren().add(borderPane);
root.getChildren().add(content);
primaryStage.setScene(scene);
primaryStage.show();

optionBorderPane= new BorderPane();
optionBorderPane.getStyleClass().add("optionContent");
// optionBorderPane.getStyleClass().add("optionContent");
optionBorderPane.getStyleClass().add("background");
optionBorderPane.setOpacity(0);
contentPane = new HBox();


contentPane.getStyleClass().add("ContentPane");
// contentPane.getStyleClass().add("ContentPane");


contentPane.setPrefHeight(primaryStage.getHeight()-100);
Expand Down Expand Up @@ -244,9 +248,7 @@ else if (opt == "i"){
String name = student.get(field.get("NAME"));
int grade = Integer.parseInt(student.get(field.get("GR")));
Student st = new Student (name,grade,id);
System.out.println(student.get(field.get("TIME")));
st.setTime(student.get(field.get("TIME")));
System.out.println(student.get(field.get("TIME")));
st.setReason(student.get(field.get("REASON")));
st.setDate(student.get(field.get("DATE")));
list.add(st);
Expand Down
20 changes: 13 additions & 7 deletions src/JavaFXGUI/StartTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public StartTab(MenuTabPane p, String title, HashMap<String, StudentList> data,
content.setBottom(menuBar);
alert = new AnimatedAlertBox("Submission Sucessful!", false);
content.setTop(alert);

menuBar.getStyleClass().add("background");
settings.getStyleClass().add("settings");
setContent(content);
switchMode();

Expand Down Expand Up @@ -132,6 +133,7 @@ public void switchMode(){
submitButton.setDefaultButton(true);
submitButton.setPrefSize(100, 20);
submitButton.setOnAction(e -> submitButton());
submitButton.getStyleClass().add("submitButton");
labelHBox.getChildren().addAll(studentIDLabel);
labelHBox.setAlignment(Pos.CENTER);

Expand Down Expand Up @@ -182,18 +184,19 @@ public void handle(MouseEvent click) {

}
else{
HBox contentHBox = new HBox();
VBox contentHBox = new VBox();
contentHBox.setAlignment(Pos.CENTER);
contentHBox.setPadding(new Insets(15, 12, 15, 12));
contentHBox.setSpacing(10);
contentHBox.getStyleClass().add("background");

Button buttonSignIn = new Button("Student Sign In");
buttonSignIn.setPrefSize(300, 50);
Button buttonSignIn = new Button("STUDENT SIGN IN");
buttonSignIn.setPrefSize(300, 60);
buttonSignIn.setOnAction(e -> moveOn(true));
buttonSignIn.getStyleClass().add("signButton");

Button buttonSignOut = new Button("Student Sign Out");
buttonSignOut.setPrefSize(300, 50);
Button buttonSignOut = new Button("STUDENT SIGN OUT");
buttonSignOut.setPrefSize(300, 60);
buttonSignOut.setOnAction(e -> moveOn(false));
buttonSignOut.getStyleClass().add("signButton");

Expand Down Expand Up @@ -301,7 +304,8 @@ else if (searchTextField.getText().isEmpty()){
/**
* Handles late bus entries. The student's reason is automatically set as "Late Bus," and their time
* of arrival is recorded in the log.
* @param txt Name of student
* @param txt Keyboard input of student (name or ID)
* @param id true if the student is entering their ID, false if student is entering name
*/
public void submit(String txt, boolean id){
searchTextField.clear();
Expand All @@ -328,6 +332,8 @@ public void submit(String txt, boolean id){
try {
PrintWriter printWriter = new PrintWriter (f);
printWriter.println("DATE,ID,NAME,GR,TIME,REASON");
TimeComparator c = new TimeComparator();
data.get("in").getStudentList().sort(c);
for(Student st : data.get("in").getStudentList()){
printWriter.print("\"" + st.getDate() + "\",");
printWriter.print("\"" + st.getStudentID() + "\",");
Expand Down
4 changes: 2 additions & 2 deletions src/JavaFXGUI/TimeComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import backend.Student;

/**
* Comparator class for a student toString() that sorts by time the program is updated.
* Comparator class for a student toString() that sorts by time the student signs in/out.
* @author Ishana
*/
public class TimeComparator implements Comparator<Student>{

@Override

public int compare(Student o1, Student o2) {
return o1.getTime().compareTo(o2.getTime());
return o2.getTime().compareTo(o1.getTime());
}

}
Loading

0 comments on commit 3844678

Please sign in to comment.