Finally w2_9734022 & 9723035

parents
Pipeline #2198 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="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</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="">
<change afterPath="$PROJECT_DIR$/src/Course.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Professor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/w22/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/w22/Main.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/w22/University.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Lab.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Lab.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Student.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Student.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/University.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Faculty.java" afterDir="false" />
</list>
<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="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="1YlMVyQSDFt0xYqw42aGbDN0Cjt" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<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="4839000" />
<workItem from="1583527493436" duration="1466000" />
<workItem from="1583619206587" duration="1998000" />
<workItem from="1583653301779" duration="19637000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1493" height="250" key="GridCell.Tab.0.bottom" timestamp="1583678554599">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1583678554599" />
<state width="1493" height="250" key="GridCell.Tab.0.center" timestamp="1583678554599">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1583678554599" />
<state width="1493" height="250" key="GridCell.Tab.0.left" timestamp="1583678554599">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1583678554599" />
<state width="1493" height="250" key="GridCell.Tab.0.right" timestamp="1583678554599">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1583678554599" />
<state width="1493" height="261" key="GridCell.Tab.1.bottom" timestamp="1583658736359">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.bottom/0.0.1536.824@0.0.1536.824" timestamp="1583658736359" />
<state width="1493" height="261" key="GridCell.Tab.1.center" timestamp="1583658736359">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.center/0.0.1536.824@0.0.1536.824" timestamp="1583658736359" />
<state width="1493" height="261" key="GridCell.Tab.1.left" timestamp="1583658736359">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.left/0.0.1536.824@0.0.1536.824" timestamp="1583658736359" />
<state width="1493" height="261" key="GridCell.Tab.1.right" timestamp="1583658736359">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="261" key="GridCell.Tab.1.right/0.0.1536.824@0.0.1536.824" timestamp="1583658736359" />
<state x="465" y="238" key="com.intellij.ide.util.TipDialog" timestamp="1583653308837">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="465" y="238" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1583653308837" />
<state x="425" y="187" key="run.anything.popup" timestamp="1583677637802">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="425" y="187" key="run.anything.popup/0.0.1536.824@0.0.1536.824" timestamp="1583677637802" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1583672146646">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1583672146646" />
</component>
</project>
\ No newline at end of file
public class Course {
private String name;
private Professor professor;
private Student[] students = new Student[10];
private Lab[] labs = new Lab[10];
private int maxCapacity;
private int currentLab = 0;
private int currentCapacity = 0;
public Course(String name, Professor professor, int credit){
this.name = name;
this.professor = professor;
maxCapacity = credit;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setProfessor(Professor professor){
this.professor = professor;
}
public Professor getProfessor(){
return professor;
}
public void setStudents(Student[] students){
for(int i = 0; i < students.length; i++){
this.students[i] = students[i];
}
}
public Student[] getStudents(){
return students;
}
public int getCurrentCapacity(){
return currentCapacity;
}
public int getMaxCapacity() {
return maxCapacity;
}
public Lab[] getLabs(){
return labs;
}
public void addLab(Lab lab){
labs[currentLab] = lab;
currentLab++;
}
//Add student in course and the first lab that has capacity
public void enrollStudent(Student student){
if (currentCapacity < maxCapacity) {
students[currentCapacity] = student;
currentCapacity++;
setStudents(students);
for(int i = 0 ; i < currentLab; i++){
if(labs[i].getCurrentSize() < labs[i].getCapacity() && labs[i].isHere(student) == false){
labs[i].enrollStudent(student); //Add student to Lab if does not exit before.
break;
}
}
} else {
System.out.println("Class is full!!!");
}
}
public void printMemberClass(){
double sum = 0;
for(int i = 0; i < currentCapacity; i++){
students[i].print();
sum += students[i].getGrade();
}
double v = sum / currentCapacity;
System.out.println("Average of this class :"+v);
System.out.println();
}
}
public class Faculty {
private String name;
private Professor[] professors = new Professor[19];
private Student[] students = new Student[30];
private Course[] courses = new Course[12];
private int current = 0;
private int currentP = 0;
public Faculty(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setStudents(Student[] students){
this.students = students;
}
public Student[] getStudents(){
return students;
}
public void setCourses(Course[] courses){
this.courses = courses;
}
public void setProfessors(Professor[] professors){
this.professors = professors;
}
public Professor[] getProfessors(){
return professors;
}
public Course[] getCourses(){
return courses;
}
public void addCourse(Course course){
courses[current] = course;
current++;
}
public void enrollStudent(Student student){
for(int i = 0; i < current; i++){
if(courses[i].getCurrentCapacity() < courses[i].getMaxCapacity()){
courses[i].enrollStudent(student);
break;
}
}
}
public void addProfessor(Professor professor){
professors[currentP] = professor;
currentP++;
setProfessors(professors);
}
public boolean isStudentValid(Student student){
for(int i = 0; i < current; i++){
Student[] std = new Student[courses[i].getCurrentCapacity()];
std = courses[i].getStudents();
for(int j = 0; j < courses[i].getCurrentCapacity(); j++){
if(std[j] == student){
return true;
}
}
}
return false;
}
public boolean isCourseValid(Course course){
for(int i = 0; i < courses.length; i++){
if(courses[i] == course)
return true;
}
return false;
}
public boolean isProfessorValid(Professor professor){
for(int i = 0; i < professors.length; i++){
if(professors[i] == professor)
return true;
}
return false;
}
public void printInfo() {
System.out.println("INFORMATION ABOUT FACULTY : "+name);
System.out.println();
System.out.println("Information about professors : ");
for(int i = 0; i < currentP; i++)
professors[i].printProfessor();
System.out.println("\nInformation about students : ");
for(int i = 0; i < 3; i++){
Professor p = courses[i].getProfessor();
System.out.println("CourseOf:"+courses[i].getName()+" , CurrentCapacity:"+courses[i].getCurrentCapacity()+" , MaxCapacity:"+courses[i].getMaxCapacity()+" , NameOfProfessor:"+p.getFirstName()+p.getLastName());
courses[i].printMemberClass();
}
}
}
File added
public class Lab {
private Student[] students = new Student[20];
private double avg;
private String day;
private int capacity;
private int currentSize = 0;
private String nameTA;
public Lab(int capacity, String day, String nameTA) {
this.nameTA = nameTA;
this.capacity = capacity;
this.day = day;
}
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()+" , Capacity:"+capacity+" , Name_TA:"+nameTA+" , Day:" + day+"Current size:" + currentSize);
}
public Student[] getStudents() {
return students;
}
public void setStudents(Student[] students) {
this.students = students;
}
public double calculateAvg() {
double sum = 0;
for(int i = 0; i < 3; i++){
sum += students[i].getGrade();
}
return 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 int getCurrentSize(){
return currentSize;
}
public void printMember(){
double sum = 0;
int i;
for(i = 0; i < currentSize; i++){
students[i].print();
sum += students[i].getGrade();
}
double v = sum / i;
System.out.println("Average of : "+v);
}
public boolean isHere(Student student){
for(int i = 0; i < currentSize; i++){
if(students[i] == student)
return true;
}
return false;
}
}
File added
public class Main {
public static void main(String[] args) {
Student[] s = new Student[12];
Professor[] p = new Professor[3];
Lab[] az = new Lab[3];
Course[] c = new Course[3];
Faculty uni = new Faculty("Computer Engineering");
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);
p[0] = new Professor("p0_2", "pp0_2");
p[1] = new Professor("p3_5", "pp3_5");
p[2] = new Professor("p6_8", "pp6_8");
az[0] = new Lab(20, "Sunday", "t0_2");
az[1] = new Lab(10, "Monday", "t3_5");
az[2] = new Lab(6, "Tuesday", "t6_8");
c[0] = new Course("AP0", p[0], 20);
c[1] = new Course("AP1", p[1], 15);
c[2] = new Course("AP2", p[2], 19);
//p[0].addCourse(c[2]);
p[0].addCourse(c[0]);
p[1].addCourse(c[1]);
p[2].addCourse(c[2]);
c[0].addLab(az[0]);
c[1].addLab(az[1]);
c[2].addLab(az[2]);
az[0].enrollStudent(s[0]);
az[0].enrollStudent(s[1]);
az[0].enrollStudent(s[2]);
az[1].enrollStudent(s[3]);
az[1].enrollStudent(s[4]);
az[1].enrollStudent(s[5]);
az[2].enrollStudent(s[6]);
az[2].enrollStudent(s[7]);
az[2].enrollStudent(s[8]);
c[0].enrollStudent(s[0]);
//uni.enrollStudent(s[0]); //Add student to faculty.Student adds to first course that is empty.
c[0].enrollStudent(s[1]);
c[0].enrollStudent(s[2]);
c[1].enrollStudent(s[3]);
c[1].enrollStudent(s[4]);
c[1].enrollStudent(s[5]);
c[2].enrollStudent(s[6]);
c[2].enrollStudent(s[7]);
c[2].enrollStudent(s[8]);
for(int i = 0; i < 3; i++){
uni.addCourse(c[i]);
}
for(int i = 0; i < p.length; i++){
uni.addProfessor(p[i]);
}
//az[0].printMember();
// az[0].printLab();
uni.printInfo();
System.out.println(uni.isProfessorValid(p[0]));
System.out.println(uni.isStudentValid(s[1]));
System.out.println(uni.isCourseValid(c[0]));
}
}
public class Professor {
private String firstName;
private String lastName;
private Course[] courses = new Course[20];
private int current = 0;
public Professor(String firstName, String lastName){
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public Course[] getCourses(){
return courses;
}
public void setCourses(Course[] courses){
for(int i = 0; i < courses.length; i++){
this.courses[i] = courses[i];
}
}
public void addCourse(Course course){
courses[current] = course;
current++;
setCourses(courses);
}
public void printProfessor() {
System.out.print("FirstName:"+firstName+" , LastName:"+lastName);
for(int i = 0; i < current; i++)
System.out.print(" , NameOfClass:"+courses[i].getName());
System.out.println();
}
}
/**
* 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:"+firstName+" , LastName:"+lastName+" , StudentID:"+id+" , Grade:"+grade);
}
}
<?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