Commit 63915424 authored by Roholla's avatar Roholla

second commit

parent d675003e
Pipeline #2057 failed with stages
File added
File added
......@@ -105,12 +105,37 @@ public class Main {
}
/**
* This class is a representation of an actual lab
* It holds some info about the lab and has some useful methods
*/
public static class Lab {
/**
* array of students in the lab
*/
private Student[] students;
/**
* the average of student's grades
*/
private int avg;
/**
* the day of the week on which each lab session is held
*/
private String day;
/**
* maximum number of students
*/
private int capacity;
/**
* current number of students
*/
private int currentSize;
/**
* constructs a new lab
* @param capacity lab's capacity
* @param day the day of the week on which each lab session is held
*/
public Lab(int capacity, String day) {
students = new Student[capacity];
this.capacity = capacity;
......@@ -118,12 +143,21 @@ public class Main {
currentSize = 0;
avg = 0;
}
/**
* adds the new kid(student) to our lab if possible
* @param std the new kid
*/
public void enrollStudent(Student std) {
if (currentSize < capacity)
students[currentSize++] = std;
else
System.out.println("Lab is full!!!");
}
/**
* prints a list of the students to standard output
*/
public void print() {
for (int i = 0; i < currentSize; i++) {
System.out.print((i + 1) + ". ");
......@@ -131,31 +165,65 @@ public class Main {
}
}
/**
* @return the students array
*/
public Student[] getStudents() {
return students;
}
/**
* adds the new kids(students) to our lab one by one;
* @param students the new kids
*/
public void setStudents(Student[] students) {
for(Student si: students)
enrollStudent(si);
}
/**
* @return the average of student's grades
*/
public int getAvg() {
return avg;
}
/**
* sets the avg field to what it should be
*/
public void calculateAvg() {
int sum = 0;
for(int i = 0; i < currentSize; i++)
sum += students[i].getGrade();
avg = sum / currentSize;
}
/**
* @return the day of the week on which each lab session is held
*/
public String getDay() {
return day;
}
/**
* sets the value of day field
* @param day the new day of the week on which each lab session is held
*/
public void setDay(String day) {
this.day = day;
}
/**
* @return the capacity of the lab
*/
public int getCapacity() {
return capacity;
}
/**
* @param capacity the new capacity
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
}
......
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment