Skip to content

Commit

Permalink
Functions update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali committed Apr 29, 2021
1 parent 9baf818 commit 77ef6c4
Show file tree
Hide file tree
Showing 8 changed files with 1,044 additions and 597 deletions.
38 changes: 38 additions & 0 deletions AddFunctions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package studentgradingsystemproject;

import java.util.GregorianCalendar;
import static studentgradingsystemproject.StudentGradingSystemProject.attendances;
import static studentgradingsystemproject.StudentGradingSystemProject.courses;
import static studentgradingsystemproject.StudentGradingSystemProject.departments;
import static studentgradingsystemproject.StudentGradingSystemProject.gradeses;
import static studentgradingsystemproject.StudentGradingSystemProject.students;

/**
*
* @author gram1
*/
public class AddFunctions {
public static void add_student(int std_id, String std_no, String std_name, String std_surname, char std_gender, String std_nationality, GregorianCalendar std_birthday){
Student st =new Student(std_id, std_no, std_name, std_surname,
std_gender, std_nationality, std_birthday);
students.add(st);
}
public static void add_course(int crs_id, int dept_id, String crs_code, String crs_name) {
Course cr =new Course(crs_id, dept_id, crs_code, crs_name);
courses.add(cr);}
public static void add_department(int dept_id, String dept_name) {
Department dr =new Department(dept_id, dept_name);
departments.add(dr);}
public static void add_grades(int grd_id, int std_id, int crs_id, float grd_mt, float grd_hw, float grd_final, String grd_lgrade) {
Grades gr =new Grades(grd_id, std_id, crs_id, grd_mt, grd_hw, grd_final, grd_lgrade);
gradeses.add(gr);}
public static void add_attendance(int att_id, int std_id, int crs_id, GregorianCalendar att_date) {
Attendance at =new Attendance(att_id, std_id, crs_id, att_date);
attendances.add(at);}

}
68 changes: 68 additions & 0 deletions BackupFunctions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package studentgradingsystemproject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import static studentgradingsystemproject.StudentGradingSystemProject.attendances;
import static studentgradingsystemproject.StudentGradingSystemProject.courses;
import static studentgradingsystemproject.StudentGradingSystemProject.departments;
import static studentgradingsystemproject.StudentGradingSystemProject.gradeses;
import static studentgradingsystemproject.StudentGradingSystemProject.students;

/**
*
* @author gram1
*/
public class BackupFunctions {
public static void backup_student() throws IOException{
File outfile = new File("students.dat");
FileOutputStream outfilestream = new FileOutputStream(outfile);
ObjectOutputStream outObjectStream = new ObjectOutputStream(outfilestream);

outObjectStream.writeObject(students);
outObjectStream.close();

}
public static void backup_course() throws IOException{
File outfile = new File("courses.dat");
FileOutputStream outfilestream = new FileOutputStream(outfile);
ObjectOutputStream outObjectStream = new ObjectOutputStream(outfilestream);

outObjectStream.writeObject(courses);
outObjectStream.close();

}
public static void backup_department() throws IOException{
File outfile = new File("departments.dat");
FileOutputStream outfilestream = new FileOutputStream(outfile);
ObjectOutputStream outObjectStream = new ObjectOutputStream(outfilestream);

outObjectStream.writeObject(departments);
outObjectStream.close();

}
public static void backup_grades() throws IOException{
File outfile = new File("gradeses.dat");
FileOutputStream outfilestream = new FileOutputStream(outfile);
ObjectOutputStream outObjectStream = new ObjectOutputStream(outfilestream);

outObjectStream.writeObject(gradeses);
outObjectStream.close();

}
public static void backup_attendance() throws IOException{
File outfile = new File("attendances.dat");
FileOutputStream outfilestream = new FileOutputStream(outfile);
ObjectOutputStream outObjectStream = new ObjectOutputStream(outfilestream);

outObjectStream.writeObject(attendances);
outObjectStream.close();

}
}
86 changes: 86 additions & 0 deletions DelFunctions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package studentgradingsystemproject;

import java.util.Iterator;
import static studentgradingsystemproject.StudentGradingSystemProject.attendances;
import static studentgradingsystemproject.StudentGradingSystemProject.courses;
import static studentgradingsystemproject.StudentGradingSystemProject.departments;
import static studentgradingsystemproject.StudentGradingSystemProject.gradeses;
import static studentgradingsystemproject.StudentGradingSystemProject.students;

/**
*
* @author gram1
*/
public class DelFunctions {
public static void delete_student(int std_id) {
Student st=null;
Boolean found=false;
Iterator <Student> itr = students.iterator();
while (itr.hasNext()) {
st = itr.next();
if(std_id==st.getStd_id()) {
found=true;
break;
}
}
if (found) students.remove(st);
}
public static void delete_course(int crs_id) {
Course cr=null;
Boolean found=false;
Iterator <Course> itr = courses.iterator();
while (itr.hasNext()) {
cr = itr.next();
if(crs_id==cr.getCrs_id()) {
found=true;
break;
}
}
if (found) courses.remove(cr);
}
public static void delete_department(int dept_id) {
Department dr=null;
Boolean found=false;
Iterator <Department> itr = departments.iterator();
while (itr.hasNext()) {
dr = itr.next();
if(dept_id==dr.getDept_id()) {
found=true;
break;
}
}
if (found) departments.remove(dr);
}
public static void delete_grades(int grd_id) {
Grades gr=null;
Boolean found=false;
Iterator <Grades> itr = gradeses.iterator();
while (itr.hasNext()) {
gr = itr.next();
if(grd_id==gr.getGrd_id()) {
found=true;
break;
}
}
if (found) gradeses.remove(gr);
}
public static void delete_attendance(int att_id) {
Attendance at=null;
Boolean found=false;
Iterator <Attendance> itr = attendances.iterator();
while (itr.hasNext()) {
at = itr.next();
if(att_id==at.getAtt_id()) {
found=true;
break;
}
}
if (found) attendances.remove(at);
}

}
122 changes: 122 additions & 0 deletions EditFunctions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package studentgradingsystemproject;

import java.util.GregorianCalendar;
import java.util.Iterator;
import static studentgradingsystemproject.StudentGradingSystemProject.attendances;
import static studentgradingsystemproject.StudentGradingSystemProject.courses;
import static studentgradingsystemproject.StudentGradingSystemProject.departments;
import static studentgradingsystemproject.StudentGradingSystemProject.gradeses;
import static studentgradingsystemproject.StudentGradingSystemProject.students;

/**
*
* @author gram1
*/
public class EditFunctions {

/**
*
* @param std_id
* @param std_no
* @param std_name
* @param std_surname
* @param std_gender
* @param std_nationality
* @param std_birthday
*/
public static void edit_student(int std_id, String std_no, String std_name, String std_surname, char std_gender, String std_nationality, GregorianCalendar std_birthday) {

Student st=null;
Boolean found=false;
Iterator <Student> itr = students.iterator();
while (itr.hasNext()) {
st = itr.next();
if(std_id==st.getStd_id()) {
found=true;
break;
}
}
if (found) {
st.setStd_no(std_no);
st.setStd_name(std_name);
st.setStd_surname(std_surname);
st.setStd_nationality(std_nationality);
st.setStd_gender(std_gender);
st.setStd_birthdate(std_birthday);
}
}
public static void edit_course(int crs_id, int dept_id, String crs_code, String crs_name) {

Course cr =null;
Boolean found=false;
Iterator <Course> itr = courses.iterator();
while (itr.hasNext()) {
cr = itr.next();
if(crs_id==cr.getCrs_id()) {
found=true;
break;
}
}
if (found) {
cr.setCrs_code(crs_code);
cr.setCrs_name(crs_name);
}
}
public static void edit_department(int dept_id, String dept_name) {

Department dr =null;
Boolean found=false;
Iterator <Department> itr = departments.iterator();
while (itr.hasNext()) {
dr = itr.next();
if(dept_id==dr.getDept_id()) {
found=true;
break;
}
}
if (found) {
dr.setDept_name(dept_name);
}
}
public static void edit_grades(int grd_id, int std_id, int crs_id, float grd_mt, float grd_hw, float grd_final, String grd_lgrade) {

Grades gr =null;
Boolean found=false;
Iterator <Grades> itr = gradeses.iterator();
while (itr.hasNext()) {
gr = itr.next();
if(grd_id == gr.getGrd_id()) {
found=true;
break;
}
}
if (found) {
gr.setGrd_mt(grd_mt);
gr.setGrd_hw(grd_hw);
gr.setGrd_final(grd_final);
gr.setGrd_lgrade(grd_lgrade);
}
}
public static void edit_attendance(int att_id, int std_id, int crs_id, GregorianCalendar att_date) {

Attendance at =null;
Boolean found=false;
Iterator <Attendance> itr = attendances.iterator();
while (itr.hasNext()) {
at = itr.next();
if(att_id==at.getAtt_id()) {
found=true;
break;
}
}
if (found) {
at.setAtt_date(att_date);
}
}

}
Loading

0 comments on commit 77ef6c4

Please sign in to comment.