State of workshop2

parents
Pipeline #2157 failed with stages
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/w22.iml" filepath="$PROJECT_DIR$/w22.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="2fc8dee6-dc07-4947-87ed-795929e1f6f3" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectId" id="1YlMVyQSDFt0xYqw42aGbDN0Cjt" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" />
<module name="w22" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="2fc8dee6-dc07-4947-87ed-795929e1f6f3" name="Default Changelist" comment="" />
<created>1583512754291</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1583512754291</updated>
<workItem from="1583512755984" duration="4223000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1493" height="225" key="GridCell.Tab.0.bottom" timestamp="1583516632630">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="225" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1583516632630" />
<state width="1493" height="225" key="GridCell.Tab.0.center" timestamp="1583516632629">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="225" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1583516632629" />
<state width="1493" height="225" key="GridCell.Tab.0.left" timestamp="1583516632629">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="225" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1583516632629" />
<state width="1493" height="225" key="GridCell.Tab.0.right" timestamp="1583516632630">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="225" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1583516632630" />
</component>
</project>
\ No newline at end of file
public class Lab {
private Student[] students = new Student[10];
private double avg;
private String day;
private int capacity;
private int currentSize = 0;
public Lab(int cap, String d) {
capacity = cap;
day = d;
}
public void enrollStudent(Student std) {
if (currentSize < capacity) {
students[currentSize] = std;
currentSize++;
setStudents(students);
} else {
System.out.println("Lab is full!!!");
}
}
public void printLab() {
System.out.println("Average = " + getAvg());
System.out.println("Capacity = " + capacity);
System.out.println("Day = " + day);
System.out.println("Current size = " + currentSize);
}
public Student[] getStudents() {
return students;
}
public void setStudents(Student[] students) {
this.students = students;
capacity = students.length;
}
public double calculateAvg() {
double sum = 0;
for(int i = 0; i < 3; i++){
sum += students[i].getGrade();
}
return (double)sum / currentSize;
}
public double getAvg(){
return calculateAvg();
}
public String getDay() {
return day;
}
public void setAvg(String day){
this.day = day;
}
public int getCapacity() {
return capacity;
}
public void setCapacity(int cap){
capacity = cap;
}
public void printMember(){
double sum = 0;
int i;
for(i = 0; i < currentSize; i++){
System.out.println((i+1)+")fName:"+students[i].getFirstName());
System.out.println((i+1)+")lName:"+students[i].getLastName());
System.out.println((i+1)+")ID:"+students[i].getId());
System.out.println((i+1)+")grade:"+students[i].getGrade());
sum += students[i].getGrade();
}
double v = sum / i;
System.out.println("Average of : "+v);
}
}
public class Main {
public static void main(String[] args) {
Student[] s = new Student[12];
s[0] = new Student("s0", "ss0", "0000000", 18);
s[1] = new Student("s1", "ss1", "1111111", 12);
s[2] = new Student("s2", "ss2", "2222222", 10);
s[3] = new Student("s3", "ss3", "3333333", 14);
s[4] = new Student("s4", "ss4", "4444444", 20);
s[5] = new Student("s5", "ss5", "5555555", 18);
s[6] = new Student("s6", "ss6", "6666666", 19);
s[7] = new Student("s7", "ss7", "7777777", 17);
s[8] = new Student("s8", "ss8", "8888888", 11);
//System.out.println(s[2].getGrade());
/*s1.setGrade(15);
s1.print();
s2.print();
s2.setFirstName("hhh");
s2.print();
s3.print();*/
//System.out.println(s3.getId());
Lab[] az = new Lab[9];
az[0] = new Lab(20, "Sunday");
az[1] = new Lab(10, "Monday");
az[2] = new Lab(3, "Tuesday");
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
az[i].enrollStudent(s[j]);
}
}
University uni = new University("Computer Engineering", 3);
for(int i = 0; i < 3; i++){
uni.enrollLab(az[i]);
}
System.out.println("Name of university : "+uni.getName());
System.out.println("Number of labs : "+uni.getCurrentLab());
System.out.println("Capasity of university : "+uni.getSum());
System.out.println("Average of all of students in university : "+uni.getAverage());
}
}
/**
* The student class represents a student in a student administration system.
* It holds the students details relevant in our context.
*
* @author MohammadaliKeshtparvar & ArminRezaei
* @version 0.0
*/
public class Student {
// the student's first name.
private String firstName;
// the student's last name.
private String lastName;
// the student ID.
private String id;
// the grade.
private int grade;
/**
* Create a new student with a given name and ID number.
*
* @param fName first name of student.
* @param lName last name of student.
* @param sID student ID.
*/
public Student (String fName, String lName, String sID, int sGrade){
firstName = fName;
lastName = lName;
id = sID;
grade = sGrade;
/*setFirstName(fName);
setLastName(lName);
setId(sID);
setGrade(sGrade);*/
}
/**
* Get the first name of student.
* @return firstName field.
*/
public String getFirstName() {
return firstName;
}
/**
*
* @param fName set first name of a student.
*/
public void setFirstName(String fName) {
firstName = fName;
}
/**
* Get the first name of student.
* @return firstName field.
*/
public String getLastName() {
return lastName;
}
/**
*
* @param lName set first name of a student.
*/
public void setLastName(String lName) {
lastName = lName;
}
/**
* Get the last name of student.
* @return lastName field.
*/
public String getId() {
return id;
}
/**
*
* @param sID set id of a student.
*/
public void setId(String sID) {
id = sID;
}
/**
* Get the grade of student.
* @return grade field.
*/
public int getGrade() {
return grade;
}
/**
*
* @param sGrade set grade of a student.
*/
public void setGrade(int sGrade) {
grade = sGrade;
}
/**
* Print the student's name and id number to the output terminal.
*/
public void print() {
System.out.println(firstName+""+lastName+" , StudentID:"+id+" , Grade:"+grade);
}
}
public class University {
private Lab[] lab = new Lab[20];
private double average;
private int currentLab = 0;
private String name;
private int sum;
public University(String name, int sum) {
this.name = name;
this.sum = sum;
}
public void enrollLab(Lab c) {
if (currentLab < sum) {
lab[currentLab] = c;
currentLab++;
setLab(lab);
} else {
System.out.println("Lab is full!!!");
}
}
public void setLab(Lab[] lab) {
this.lab = lab;
}
public Lab[] getLab() {
return lab;
}
public int getCurrentLab() {
return currentLab;
}
public void setCurrentLab(int currentLab) {
this.currentLab = currentLab;
}
public double calculating() {
double sum = 0;
for(int i = 0; i < currentLab; i++){
sum += lab[i].getAvg();
}
return (double)sum / currentLab;
}
public double getAverage() {
return calculating();
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
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