Commit 8a836280 authored by 9831045's avatar 9831045

initial commit

parents
Pipeline #2143 failed with stages
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="true" project-jdk-name="13 (2)" 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$/Run.iml" filepath="$PROJECT_DIR$/Run.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="721d25be-807f-4a41-a78a-d223bc93b2f4" 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="1YkgsSC8Xg5K755bG14UR2JIGI5" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
</component>
<component name="RunManager">
<configuration name="Run" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Run" />
<module name="Run" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Run" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="721d25be-807f-4a41-a78a-d223bc93b2f4" name="Default Changelist" comment="" />
<created>1583492212783</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1583492212783</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="275" y="21" key="#Project_Structure" timestamp="1583492226195">
<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="181" key="GridCell.Tab.0.bottom" timestamp="1583492438374">
<screen x="0" y="0" width="1366" height="728" />
</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="181" key="GridCell.Tab.0.center" timestamp="1583492438374">
<screen x="0" y="0" width="1366" height="728" />
</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="181" key="GridCell.Tab.0.left" timestamp="1583492438374">
<screen x="0" y="0" width="1366" height="728" />
</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="181" key="GridCell.Tab.0.right" timestamp="1583492438374">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state width="1366" height="181" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1583492438374" />
</component>
</project>
\ No newline at end of file
<?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
public class Lab {
private Student[] students;
private int avg;
private String day;
private int capacity;
private int currentSize;
/**
* constructor
*
* @param cap is the lab capacity
* @param d is the date
*/
public Lab(int cap, String d) {
capacity = cap;
day = d;
currentSize = 0;
}
/**
* checks if the student can enroll to the class
*/
public void enrollment(Student std) {
if (currentSize < capacity) {
students[currentSize] = std;
currentSize++;
} else {
System.out.println("lab is full!!!");
}
}
/**
* prints
*/
public void print() {
/*
// System.out.println("capacity: " + capacity + "current size: " + );
int i = 0;
for(Student s : students){
// System.out.println(i + ")" + "first name: " + s.getFirstName() + "last name: " + s.getGrade());
System.out.print(i + ")" );
s.print();
}
*/
for (int i = 0; i < students.length; i++) {
System.out.println("std fname: " + students[i].getFirstName() + " std id:" + students[i].getId() + " std grade:" + students[i].getGrade());
} System.out.println("Lab AVG:" + avg);
}
/**
* getter for students
*
* @return the students list as an array
*/
public Student[] getStudents() {
return students;
}
/**
* setter for students
*
* @param students is the new students list
*/
public void setStudents(Student[] students) {
this.students = students;
}
/**
* getter for average
* @return avg average
*/
public int getAvg() {
return avg;
}
/**
* calculates the students average
*/
public void calculateAvg() {
int sum = 0;
int i = 0;
for (; i < students.length; i++) {
sum += students[i].getGrade();
}
avg = sum / i;
}
/**
* getter for day
* @return day
*/
public String getDay() {
return day;
}
/**
* a setter for day
* @param day will set the day
*/
public void setDay(String day){
this.day = day;
}
/**
* a getter for capacity
* @return the class capacity
*/
public int getCapacity() {
return capacity;
}
/**
* a setter for capacity
* @param capacity will be the new lab capacity
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
}
}
import java.util.ArrayList;
public class Run {
public static void main(String[] args) {
Student std1 = new Student("Ehsan", "Edalat", "9031066");
Student std2 = new Student("Seyed", "Ahmadpanah", "9031806");
Student std3 = new Student("Ahmad", "Asadi", "9031054");
std1.print();
std1.setGrade(15);
std1.print();
std2.print();
std2.setGrade(11);
std2.print();
std3.print();
std3.setFirstName("HamidReza");
std3.print();
}
}
public class Student {
private String firstName;
private String lastName;
private String id;
private int grade;
/**
* creat a new stdent nam and id number
* @param fName first name of student
* @param lname last name iof student
* @param sID student ID
*/
public Student(String fName, String lname, String sID){
firstName = fName;
lastName = lname;
id = sID;
grade = 0;
}
/**
*get the first name of a student
* @return firstName field
*/
public String getFirstName(){
return firstName;
}
/**
* @param firstName set first nameof a student
*/
public void setFirstName( String fName){
firstName = fName;
}
/**
* print the students last name and ID number to the output terminal
*/
public void print(){
System.out.println(firstName + " " + lastName + " , student ID: " + id + " , grade: " + grade);
}
/**
* getter and setter for both id and grade
* @param score represents the grade of the student
*/
public void setGrade(int score){
if( score < 20 && score >= 0 ) {
grade = score;
}
else
System.out.println("error grade");
}
public int getGrade(){
return grade;
}
public void setId(String fId){
if( fId.length() == 7 ) {
id = fId;
}
else
System.out.println("error");
}
public String getId(){
return id;
}
}
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