Commit c07c04d8 authored by 9831045's avatar 9831045

added extra testings

parent 2c6b6869
......@@ -3,6 +3,9 @@
<component name="ChangeListManager">
<list default="true" id="721d25be-807f-4a41-a78a-d223bc93b2f4" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Run/Lab.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Run/Lab.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Run/Run.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Run/Run.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/Run/Student.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/Run/Student.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Lab.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Lab.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Run.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Run.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Student.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Student.java" afterDir="false" />
......@@ -69,22 +72,22 @@
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="275" y="21" key="#Project_Structure/0.0.1366.728@0.0.1366.728" timestamp="1583492226195" />
<state width="1366" height="180" key="GridCell.Tab.0.bottom" timestamp="1583500264815">
<state width="1366" height="180" key="GridCell.Tab.0.bottom" timestamp="1583501471086">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1366" height="180" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1583500264815" />
<state width="1366" height="180" key="GridCell.Tab.0.center" timestamp="1583500264814">
<state width="1366" height="180" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1583501471086" />
<state width="1366" height="180" key="GridCell.Tab.0.center" timestamp="1583501471086">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1366" height="180" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1583500264814" />
<state width="1366" height="180" key="GridCell.Tab.0.left" timestamp="1583500264814">
<state width="1366" height="180" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1583501471086" />
<state width="1366" height="180" key="GridCell.Tab.0.left" timestamp="1583501471086">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1366" height="180" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1583500264814" />
<state width="1366" height="180" key="GridCell.Tab.0.right" timestamp="1583500264814">
<state width="1366" height="180" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1583501471086" />
<state width="1366" height="180" key="GridCell.Tab.0.right" timestamp="1583501471086">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1366" height="180" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1583500264814" />
<state width="1366" height="180" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1583501471086" />
<state x="184" y="0" key="SettingsEditor" timestamp="1583493438190">
<screen x="0" y="0" width="1366" height="728" />
</state>
......
......@@ -25,6 +25,7 @@ public class Lab {
if (currentSize < capacity) {
students[currentSize] = std;
currentSize++;
calculateAvg();
} else {
System.out.println("lab is full!!!");
}
......@@ -68,9 +69,11 @@ public class Lab {
currentSize = 0;
for (Student i : students) {
this.students[j] = new Student(i.getFirstName(),i.getLastName(),i.getId());
this.students[j].setGrade(i.getGrade());
j++;
currentSize++;
}
calculateAvg();
}
......@@ -88,7 +91,7 @@ public class Lab {
public void calculateAvg() {
int sum = 0;
int i = 0;
for (; i < students.length; i++) {
for (; i < currentSize ; i++) {
sum += students[i].getGrade();
}
avg = sum / i;
......
......@@ -7,10 +7,7 @@ public class Run {
Student std3 = new Student("Ahmad", "Asadi", "9031054");
//creating a students array
Student[] students = new Student[3];
//initializing the students in the array
students[0] = std1;
students[1] = std2;
students[2] = std3;
//running the simple functions in the AP manual
std1.print();
std1.setGrade(15);
......@@ -23,23 +20,51 @@ public class Run {
std3.print();
std3.setFirstName("HamidReza");
std3.print();
//printing an error message when the grade is invalid
std1.setGrade(21);
std2.setGrade(-1);
//no problem when the grade is fine
std1.setGrade(20);
std2.setGrade(19);
//setting the new ID
std3.setId("9034212");
//initializing the students in the array
students[0] = std1;
students[1] = std2;
students[2] = std3;
//running extra functions
//setting the day
String day = new String("98/1/23");
//setting the capacity
int cap = 3;
//initializing Lab constructor
Lab lab = new Lab(cap,day);
//setting the students
lab.setStudents(students);
//calulating the average
lab.calculateAvg();
//using labs print method
lab.print();
//now lets set a new day
String newDay = new String("98/2/2");
lab.setDay(newDay);
System.out.println( "this is the new lab day -> " + lab.getDay());
//now to show that no one can attend the lab when its full
Student std4 = new Student("new students first name","new students last name ","9031059");
//now to show that no one can attend the lab when its full this will cause an error message
Student std4 = new Student("new first name","new last name ","9031059");
lab.enrollment(std4);
//now lets increase the classes capacity
......@@ -47,17 +72,12 @@ public class Run {
//the new lab student can be enrolled
lab.enrollment(std4);
//printing the labs new list
students = lab.getStudents();
students[0].print();
students[1].print();
students[2].print();
students[3].print();
lab.print();
//what if we want to get the student array itself
students = lab.getStudents();
//printing the new average because we just added std4
System.out.println("The new lab average is = " + lab.getAvg());
}
}
......
......@@ -41,7 +41,7 @@ public class Student {
* @param score represents the grade of the student
*/
public void setGrade(int score){
if( score < 20 && score >= 0 ) {
if( score <= 20 && score >= 0 ) {
grade = score;
}
else
......
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