-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBatch.java
More file actions
70 lines (63 loc) · 2.43 KB
/
Batch.java
File metadata and controls
70 lines (63 loc) · 2.43 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.*;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Batch {
// class Identification Parameters
//private static Batch instance;
int classStrength;
String branch;
int Gradyear;
Student[] students;
public Batch(String path1,String path2) {
try{
int num=0,number;
File file1=new File(path1);
File file2=new File(path2);
FileReader fr1=new FileReader(file1);
FileReader fr2=new FileReader(file2);
BufferedReader br1=new BufferedReader(fr1);
BufferedReader br2=new BufferedReader(fr2);
String line="";
String[] temparr,info;
line=br1.readLine();
temparr=line.split(",");
this.classStrength = Integer.parseInt(temparr[2]);
this.branch = temparr[0];
this.Gradyear = Integer.parseInt(temparr[1]);
this.students = new Student[this.classStrength];
number=Integer.parseInt(br2.readLine());
for(int i=0;i<this.classStrength;i++){
line=br1.readLine();
info=line.split(",");
this.students[i] = new Student(Integer.parseInt(info[0]), info[1], info[2], Long.parseLong(info[3]), info[4]);
num=Integer.parseInt(br2.readLine());
this.students[i].setAttendence(num);
this.students[i].totalLabs=number;
}
br1.close();
br2.close();
}
catch(IOException ex){
ex.printStackTrace();
}
}
public String toString() {
String info = "\n";
System.out.printf("%-8s | %-10s | %-15s | %-15s | %-25s\n","Roll No.", "ID Number", "Name", "Contact Number","Email ID");
System.out.printf("------------------------------------------------------------------------------------\n");
for (int i = 0; i < this.classStrength; i++) {
System.out.printf("%5d | %-10s | %-15s | %-15d | %-25s\n", students[i].rollNo, students[i].id, students[i].name, students[i].getContactNumber(), students[i].getEmailID());
}
return " ";
}
public Student getStudentById(String id){
for(int i=0;i<this.classStrength;i++){
if(id.equals(this.students[i].id)){
return this.students[i];
}
}
return null;
}
}