Commit 88df324f authored by 9831045's avatar 9831045

added extra function testing

parent 8a836280
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="721d25be-807f-4a41-a78a-d223bc93b2f4" name="Default Changelist" comment="" /> <list default="true" id="721d25be-807f-4a41-a78a-d223bc93b2f4" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1YkgsSC8Xg5K755bG14UR2JIGI5" /> <component name="ProjectId" id="1YkgsSC8Xg5K755bG14UR2JIGI5" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" /> <option name="showExcludedFiles" value="true" />
...@@ -15,9 +32,11 @@ ...@@ -15,9 +32,11 @@
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="project.structure.last.edited" value="Modules" /> <property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" /> <property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" /> <property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
</component> </component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Run" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Run" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
...@@ -51,21 +70,25 @@ ...@@ -51,21 +70,25 @@
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="275" y="21" key="#Project_Structure/0.0.1366.728@0.0.1366.728" timestamp="1583492226195" /> <state x="275" y="21" key="#Project_Structure/0.0.1366.728@0.0.1366.728" timestamp="1583492226195" />
<state width="1366" height="181" key="GridCell.Tab.0.bottom" timestamp="1583492438374"> <state width="1366" height="180" key="GridCell.Tab.0.bottom" timestamp="1583495551043">
<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="1583495551043" />
<state width="1366" height="180" key="GridCell.Tab.0.center" timestamp="1583495551042">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state width="1366" height="181" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1583492438374" /> <state width="1366" height="180" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1583495551042" />
<state width="1366" height="181" key="GridCell.Tab.0.center" timestamp="1583492438374"> <state width="1366" height="180" key="GridCell.Tab.0.left" timestamp="1583495551042">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state width="1366" height="181" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1583492438374" /> <state width="1366" height="180" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1583495551042" />
<state width="1366" height="181" key="GridCell.Tab.0.left" timestamp="1583492438374"> <state width="1366" height="180" key="GridCell.Tab.0.right" timestamp="1583495551042">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state width="1366" height="181" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1583492438374" /> <state width="1366" height="180" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1583495551042" />
<state width="1366" height="181" key="GridCell.Tab.0.right" timestamp="1583492438374"> <state x="184" y="0" key="SettingsEditor" timestamp="1583493438190">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state width="1366" height="181" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1583492438374" /> <state x="184" y="0" key="SettingsEditor/0.0.1366.728@0.0.1366.728" timestamp="1583493438190" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -9,11 +9,12 @@ public class Lab { ...@@ -9,11 +9,12 @@ public class Lab {
* constructor * constructor
* *
* @param cap is the lab capacity * @param cap is the lab capacity
* @param d is the date * @param day is the date
*/ */
public Lab(int cap, String d) { public Lab(int cap, String day) {
students = new Student[100];
capacity = cap; capacity = cap;
day = d; this.day = day;
currentSize = 0; currentSize = 0;
} }
...@@ -63,7 +64,11 @@ public class Lab { ...@@ -63,7 +64,11 @@ public class Lab {
* @param students is the new students list * @param students is the new students list
*/ */
public void setStudents(Student[] students) { public void setStudents(Student[] students) {
this.students = students; int j =0 ;
for (Studenti : students){
this.students[j] = i;
j++;
}
} }
...@@ -116,6 +121,15 @@ public class Lab { ...@@ -116,6 +121,15 @@ public class Lab {
*/ */
public void setCapacity(int capacity) { public void setCapacity(int capacity) {
this.capacity = capacity; this.capacity = capacity;
Student[] students1 = new Student[capacity];
for (int i = 0 ; i < students.length && i < capacity ; i++){
students1[i] = students[i];
}
students = new Student[capacity];
for (int i=0 ; i < capacity ; i++ ){
students[i] = students1[i];
}
} }
} }
...@@ -5,7 +5,13 @@ public class Run { ...@@ -5,7 +5,13 @@ public class Run {
Student std1 = new Student("Ehsan", "Edalat", "9031066"); Student std1 = new Student("Ehsan", "Edalat", "9031066");
Student std2 = new Student("Seyed", "Ahmadpanah", "9031806"); Student std2 = new Student("Seyed", "Ahmadpanah", "9031806");
Student std3 = new Student("Ahmad", "Asadi", "9031054"); 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.print();
std1.setGrade(15); std1.setGrade(15);
std1.print(); std1.print();
...@@ -17,6 +23,31 @@ public class Run { ...@@ -17,6 +23,31 @@ public class Run {
std3.print(); std3.print();
std3.setFirstName("HamidReza"); std3.setFirstName("HamidReza");
std3.print(); std3.print();
//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);
//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");
lab.enrollment(std4);
//now lets increase the classes capacity
lab.setCapacity(4);
//the new lab student can be enrolled
lab.enrollment(std4);
//printing the labs new list
lab.print();
} }
......
...@@ -24,7 +24,7 @@ public class Student { ...@@ -24,7 +24,7 @@ public class Student {
} }
/** /**
* @param firstName set first nameof a student * @param fName set firstname of a student
*/ */
public void setFirstName( String fName){ public void setFirstName( String fName){
firstName = fName; firstName = fName;
......
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