Commit d41f9fff authored by mohammadMotevali's avatar mohammadMotevali

Initial commit

parents
Pipeline #2230 failed with stages
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KHW2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
File added
public class Run {
public static void main(String[] args) {
Student std1 = new Student("mohammad", "motevali", "9831100");
Student std2 = new Student("ali", "motevali", "9831200");
std1.display();
std1.setGrade(20);
System.out.println(std1.getFirstName());
std1.display();
}
}
\ No newline at end of file
/**
*
* @author mohammad
* @since 2020
*
*/
public class Student {
private String firstName;
private String lastName;
private String id;
private int grade;
/**
* create a new student:
*
* @param fName this is first name of student
* @param lName this is last name of student
* @param id this is student number
*/
public Student(String fName, String lName, String id) {
firstName = fName;
lastName = lName;
this.id = id;
grade = 0;
}
/**
* get the first name of student
* @return firstName
*/
public String getFirstName() {
return firstName;
}
/**
*
* @param firstName set for name
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* get the last name of student
* @return lastName
*/
public String getLastName() {
return lastName;
}
/**
*
* @param lastName set for last name
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* get the id of student
* @return id
*/
public String getId() {
return id;
}
/**
*
* @param id set id(7 digit)
*/
public void setId(String id) {
if( id.length() == 7 ) {
this.id = id;
}
}
/**
*
* @param grade set for grade of student
*/
public void setGrade(int grade) {
this.grade = grade;
}
/**
* print the information of student
*/
public void display() {
System.out.println(lastName + " student id: " + id +" grade: " + grade);
}
}
\ 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