Commit a4ba78a6 authored by 9831133's avatar 9831133

Update Lab.java

parent b32b0f8a
public class Lab{ public class Lab{
Student[] students= new Student[6]; Student[] students= new Student[6];
private int avg; private int avg;
// the average
private String day; private String day;
// the day
private int capacity; private int capacity;
// the capacity of the class
private int currentSize; private int currentSize;
// the current size of the class
public Lab(int cap,String d){ public Lab(int cap,String d){
capacity=cap; capacity=cap;
day=d; day=d;
currentSize=0; currentSize=0;
} }
public void calculateavg(){ public void calculateavg(){
int x; int x;
int sum=0; int sum=0;
for(int i=0 ; i<3 ; i++){ for(int i=0 ; i<3 ; i++){
x=students[i].getGrade(); x=students[i].getGrade();
sum=sum+x; sum=sum+x;
} }
avg=sum/3; avg=sum/3;
} }
/** // This function calculates the average
* @param calculateavg set find average
*/
public void enrollStudent(Student std) { public void enrollStudent(Student std) {
if (currentSize < capacity) { if (currentSize < capacity) {
students[currentSize] = std; students[currentSize] = std;
...@@ -29,29 +31,44 @@ public void enrollStudent(Student std) { ...@@ -29,29 +31,44 @@ public void enrollStudent(Student std) {
System.out.println("Lab is full!!!"); System.out.println("Lab is full!!!");
} }
} }
// This function checks the capacity of the class
public void print() { public void print() {
System.out.println("avg="+avg+"tedad"+currentSize); System.out.println("avg="+avg+"tedad"+currentSize);
} }
// A function for printing
public Student[] getStudents() { public Student[] getStudents() {
return students; return students;
} }
/**
* @param students The students of the class
*/
public void setStudents(Student[] students) { public void setStudents(Student[] students) {
this. students=students; this. students=students;
} }
public int getAvg() { public int getAvg() {
return avg; return avg;
} }
/**
* @param avg The average of grades
*/
// A function for getting the average
public String getDay() { public String getDay() {
return day; return day;
} }
/**
* @param day day of the year
*/
// A function for getting the day
public void setDay(String day) { public void setDay(String day) {
this. day=day; this. day=day;
} }
public int getCapacity() { public int getCapacity() {
return capacity; return capacity;
} }
// A function that gets the capacity
public void setCapacity(int capacity) { public void setCapacity(int capacity) {
this. capacity=capacity; this. capacity=capacity;
} }
// A function that sets the capacity
} }
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