Skip to content

Develop #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions exercise1/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions exercise1/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions exercise1/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions exercise1/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion exercise1/Human.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public void sayMyName() {
System.out.println("im a human!");
}

public void staticPrint() {
public final void staticPrint() {
//سوال1
System.out.println("this function should always print this string in all subclasses");
}
}
20 changes: 20 additions & 0 deletions exercise1/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@

public class Main {
public static void main(String[] args) {
//سوال 6
Human student=new Student();
Human professor=new Professor();

System.out.println(student instanceof Human); //true
System.out.println(professor instanceof Human); //true


//سوال7
Human human1=new Student();
human1.sayMyName();
//output:My name is null


//سوال 8
Human human2 = new Professor();
human2.sayMyName();
/* output:
My name is null
The professorFaculty is null
*/
}
}
39 changes: 37 additions & 2 deletions exercise1/Professor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,40 @@
// 4.Add the following attributes to this class with setters and getters: professorSpecialty, professorFaculty, numberOfCourse
// 5.Change the professor class so that when we call the sayMyName() method on an instance of this class, fullName of the professor plus their professorFaculty is printed.

public class Professor {
}

public class Professor extends Human{
// سوال 4
private String professorFaculty;
private String professorSpecialty;
private int numberOfCourse;

public String getProfessorFaculty(){
return professorFaculty;
}
public void setProfessorFaculty(String professorFaculty){
this.professorFaculty=professorFaculty;
}
public String getProfessorSpecialty(){
return professorSpecialty;
}
public void setProfessorSpecialty(String professorSpecialty){
this.professorSpecialty=professorSpecialty;
}
public int getNumberOfCourse(){
return numberOfCourse;
}
public void setNumberOfCourse(int numberOfCourse){
this.numberOfCourse=numberOfCourse;
}


@Override
//سوال 5
public void sayMyName(){
System.out.println("My name is " + getFullName());
System.out.println("The professorFaculty is "+ getProfessorFaculty());
}

}


36 changes: 34 additions & 2 deletions exercise1/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,37 @@
// 2. Change the student class so that when we call the sayMyName() method on an instance of this class, the fullName attribute of the student is printed.
// 3.Add the following attributes to the student class with setters and getters: studentNumber, majorName, universityName

public class Student {
}

public class Student extends Human{
// سوال 3
private int studentNumber;
private String majorName;
private String universityName;

public int getStudentNumber(){
return studentNumber;
}
public void setStudentNumber(int studentNumber){
this.studentNumber=studentNumber;
}
public String getMajorName(){
return majorName;
}
public void setMajorName(String majorName){
this.majorName=majorName;
}
public String getUniversityName(){
return universityName;
}
public void setUniversityName(String universityName){
this.universityName=universityName;
}


@Override
//سوال 2
public void sayMyName(){
System.out.println("My name is " + getFullName());

}
}
11 changes: 11 additions & 0 deletions exercise1/exercise1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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$" isTestSource="false" packagePrefix="exercise1" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
3 changes: 3 additions & 0 deletions exercise1/out/production/exercise1/exercise1/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions exercise1/out/production/exercise1/exercise1/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions exercise1/out/production/exercise1/exercise1/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions exercise1/out/production/exercise1/exercise1/exercise1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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$" isTestSource="false" packagePrefix="exercise1" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added exercise1/سوال 9.pdf
Binary file not shown.