diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..fb89d3f
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Human.java
\ No newline at end of file
diff --git a/exercise1/.idea/.gitignore b/exercise1/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/exercise1/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/exercise1/.idea/misc.xml b/exercise1/.idea/misc.xml
new file mode 100644
index 0000000..1b2d693
--- /dev/null
+++ b/exercise1/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/.idea/modules.xml b/exercise1/.idea/modules.xml
new file mode 100644
index 0000000..7f8eec6
--- /dev/null
+++ b/exercise1/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/.idea/vcs.xml b/exercise1/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/exercise1/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/Human.java b/exercise1/Human.java
index 4b9b45e..d6f021d 100644
--- a/exercise1/Human.java
+++ b/exercise1/Human.java
@@ -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");
}
}
diff --git a/exercise1/Main.java b/exercise1/Main.java
index ad47473..0a4778c 100644
--- a/exercise1/Main.java
+++ b/exercise1/Main.java
@@ -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
+ */
}
}
diff --git a/exercise1/Professor.java b/exercise1/Professor.java
index 7c3b522..19a67d4 100644
--- a/exercise1/Professor.java
+++ b/exercise1/Professor.java
@@ -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());
+ }
+
+ }
+
+
diff --git a/exercise1/Student.java b/exercise1/Student.java
index 0f8f606..cb3fe9f 100644
--- a/exercise1/Student.java
+++ b/exercise1/Student.java
@@ -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());
+
+ }
+ }
diff --git a/exercise1/exercise1.iml b/exercise1/exercise1.iml
new file mode 100644
index 0000000..40f3192
--- /dev/null
+++ b/exercise1/exercise1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/out/production/exercise1/exercise1/.idea/.gitignore b/exercise1/out/production/exercise1/exercise1/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/exercise1/out/production/exercise1/exercise1/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/exercise1/out/production/exercise1/exercise1/.idea/misc.xml b/exercise1/out/production/exercise1/exercise1/.idea/misc.xml
new file mode 100644
index 0000000..1b2d693
--- /dev/null
+++ b/exercise1/out/production/exercise1/exercise1/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/out/production/exercise1/exercise1/.idea/modules.xml b/exercise1/out/production/exercise1/exercise1/.idea/modules.xml
new file mode 100644
index 0000000..7f8eec6
--- /dev/null
+++ b/exercise1/out/production/exercise1/exercise1/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/out/production/exercise1/exercise1/.idea/vcs.xml b/exercise1/out/production/exercise1/exercise1/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/exercise1/out/production/exercise1/exercise1/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/exercise1/out/production/exercise1/exercise1/exercise1.iml b/exercise1/out/production/exercise1/exercise1/exercise1.iml
new file mode 100644
index 0000000..40f3192
--- /dev/null
+++ b/exercise1/out/production/exercise1/exercise1/exercise1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/exercise1/\330\263\331\210\330\247\331\204 9.pdf" "b/exercise1/\330\263\331\210\330\247\331\204 9.pdf"
new file mode 100644
index 0000000..a0d7b79
Binary files /dev/null and "b/exercise1/\330\263\331\210\330\247\331\204 9.pdf" differ