128 lines
3.7 KiB
Java
128 lines
3.7 KiB
Java
/*
|
||
Author: Alejandro Santillana
|
||
Description: Builds a basic school data tracker
|
||
keeps track of students and what course they are enrolled in as well as what courses
|
||
are offered by the school.
|
||
Course information is also available
|
||
Input is read from file
|
||
*/
|
||
import javafx.application.Application;
|
||
import javafx.scene.Scene;
|
||
import javafx.scene.control.Label;
|
||
import javafx.scene.control.Button;
|
||
import javafx.scene.layout.StackPane;
|
||
import javafx.stage.Stage;
|
||
import javafx.scene.layout.GridPane;
|
||
|
||
public class App extends Application {
|
||
static public School school_;
|
||
|
||
@Override
|
||
public void start(Stage stage) {
|
||
// make the initial menu with three buttons
|
||
stage.setTitle("School App");
|
||
// main menu buttons
|
||
Button instButton = new Button("Instructors");
|
||
Button studButton = new Button("Students");
|
||
Button courButton = new Button("Courses");
|
||
|
||
// creating the initial scene to draw thigns onto
|
||
GridPane grid = new GridPane();
|
||
grid.add(instButton, 1, 0, 1, 1);
|
||
grid.add(studButton, 1, 1, 1, 1);
|
||
grid.add(courButton, 1, 2, 1, 1);
|
||
|
||
Scene scene = new Scene(grid, 1280, 720);
|
||
stage.setScene(scene);
|
||
|
||
// render the scene
|
||
stage.show();
|
||
}
|
||
public static void main(String[] args) {
|
||
// First we'll create a school
|
||
School.createSchool("CSUMB");
|
||
school_ = School.getSchool();
|
||
// Next we'll populate it with some data
|
||
school_.readData("data1.txt");
|
||
school_.readData("data2.txt");
|
||
// Next we'll create the UI
|
||
launch();
|
||
}
|
||
public static void legacy_main(String[] args) {
|
||
String dataFile1 = "data1.txt";
|
||
String dataFile2 = "data2.txt";
|
||
|
||
// course reference for demo purposes
|
||
Course course1;
|
||
Student student1;
|
||
|
||
// first we'll read in some data
|
||
System.out.println("===== Read Data 1 =====");
|
||
School.createSchool("CSUMB");
|
||
|
||
School SCD = School.getSchool();
|
||
// get all basic info about the SCD
|
||
SCD.readData(dataFile1);
|
||
|
||
System.out.println("\n===== School Info 1 =====");
|
||
SCD.schoolInfo();
|
||
|
||
// round 2 of adding info to the SCD
|
||
System.out.println("\n===== Read Data 2 =====");
|
||
SCD.readData(dataFile2);
|
||
|
||
System.out.println("\n===== School Info 2 =====");
|
||
SCD.schoolInfo();
|
||
|
||
// we'll now add some new instructors
|
||
SCD.addInstructor(700, "E. Tao", "tao@csumb.edu", "777-777-1234");
|
||
SCD.addCourse(300, "CST300 – ProSem", 700, "BIT110");
|
||
SCD.addCourse(231, "CST231 – Intro C++", 100, "BIT104");
|
||
|
||
// examples of bad courses to add
|
||
System.out.println("\n===== Failed Course Addition =====");
|
||
SCD.addCourse(306, "CST306 – GUI Dev", 250, "BIT120");
|
||
SCD.addCourse(499, "CST499 – iOS Dev", 150, "BIT104");
|
||
|
||
System.out.println("\n===== Detailed Course Info =====");
|
||
SCD.courseInfo(306);
|
||
|
||
// updateing a courses location
|
||
course1 = SCD.getCourse(205);
|
||
course1.updateLocation("Library 104");
|
||
|
||
// checking some courses' information
|
||
System.out.println("\n===== Detailed Course Info 2 =====");
|
||
SCD.courseInfo(205);
|
||
|
||
System.out.println("\n===== Detailed Course Info 3 =====");
|
||
SCD.courseInfo();
|
||
SCD.deleteCourse(231);
|
||
SCD.deleteCourse(336);
|
||
SCD.deleteCourse(338);
|
||
|
||
System.out.println("\n===== Detailed Course Info 4 =====");
|
||
SCD.courseInfo();
|
||
|
||
// adding a student (valid this time)
|
||
SCD.addStudent(5555, "Chris Watson", 205, 85.50f, "B");
|
||
System.out.println("\n===== Detailed Course Info 5 =====");
|
||
SCD.courseInfo(205);
|
||
student1 = SCD.getStudentInfo(7777);
|
||
|
||
// student info
|
||
System.out.println("\n===== Detailed Student Info =====");
|
||
System.out.println(student1);
|
||
|
||
System.out.println("\n===== Detailed Student Info 2 =====");
|
||
System.out.println(SCD.getStudentInfo(7777));
|
||
SCD.graduateStudent(5555);
|
||
|
||
System.out.println("\n===== Detailed Course Info 6 =====");
|
||
SCD.courseInfo(205);
|
||
SCD.graduateStudent(5555);
|
||
|
||
System.out.println("\n===== Good Job! Bye! =====");
|
||
}
|
||
}
|