SlideShare a Scribd company logo
the code is as the following:
package hw1;
public class Runner {
public static void main(String[] args) {
/*print top header
ID Name Gender Age CH Academic Year
*/
Student.printHeader();
/* Creates a student and prints his info.
* Parameters here are: Name, age, number of courses enrolled in,
* academic year, and gender.
* Pay attention that the ID is auto generated and does not have a setter.
* valid age is [1-100] otherwise, it is set to 1
* valid academicYear is [1-10] otherwise, it is set to 1
* valid numEnrolledCourses is [1-9] otherwise, it is set to 0
*/
//You must make this constructor call the empty constructor which sets the value of the id
Student s1 = new Student("Ahemd Ali", 20, 6, 2);
/*printStudentInfo() prints the ID, name, Age, Credit Hours, Academic year, and gender.
* credit hours is the number of courses the student is enrolled in * 3
*/
s1.printStudentInfo();
//Creates a second student and prints the students' info
//You must make this constructor call the constructor that takes all attributes but not the
gender
Student s2 = new Student("Radwan Ameer", 23, 5, 6, Gender.MALE);
s2.printStudentInfo();
//Creates a third student and prints the students' info
Student s3 = new Student();
//sets the name of s3 to Aisha Fawaz
System.out.println("Setting the name of p3 to "Aisha Fawaz"");
s3.setName("Aisha Fawaz");
//Set number of enrolled courses for Aisha to 4
System.out.println("Setting number of enrolled courses of Aisha to 4");
s3.setNumEnrolledCourses(4);
/*printStudentInfo() for s3 */
s3.printStudentInfo();
//Set number of enrolled courses of Aisha to 10!
System.out.println("Set enrolled courses to 10!");
s3.setNumEnrolledCourses(10);
/*printStudentInfo() for s3 */
s3.printStudentInfo();
//Sets the age of Aisha to 19
System.out.println("Setting Aisha's age to 19");
s3.setAge(19);
//sets the gender of Aisha to Female
s3.setGender(Gender.FEMALE);
// printStudentInfo() for s3
s3.printStudentInfo();
/*checks if s1 and s3 having the same values for all of their corresponding attributes*/
System.out.println("s1.equals(s3)? "+s1.equals(s3));
//creates student object s4
Student s4 = new Student();
/*copies data of s1 to s4*/
s1.copy(s4);
System.out.println("s4 is a copy of s1");
/*checks if s1 and s4 having the same values for all of their corresponding attributes*/
System.out.println("s1.equals(s4)? "+s1.equals(s4));
/*creates a clone of s3 and returns its reference to be saved in s5.
* s5 is a clone of s3
*/
Student s5 = s3.clone();
System.out.println("s5 is a clone of s3");
/*checks if s3 and s5 having the same values for all of their corresponding attributes*/
System.out.println("s3.equals(s5)? "+s3.equals(s5));
/*compares s1 to s2 based on the value of the attribute id.
* if the value of id of s1 is less than the value of id of s2 the method returns -1,
* if the value of id of s1 is greater than the value of id of s2 the method returns 1,
* otherwise the two values of id are equal, it returns 0.
*/
switch(s1.compareTo(s2)) {
case -1: System.out.println("s1.id<s2.id");break;
case 1: System.out.println("s1.d>s2.id");break;
case 0: System.out.println("s1.id==s2.id");break;
}
//prints all students
System.out.println();
Student.printHeader();
s1.printStudentInfo();
s2.printStudentInfo();
s3.printStudentInfo();
s4.printStudentInfo();
s5.printStudentInfo();
System.out.println("ntotal number of students is: " + Student.totalNumOfStudents);
/*
* creating course objects. Must make use of constructors chaining: constructor calls another
* the course type can be THEORY,LAB,SEMINAR,SDP,TRAINING
*/
Course c1 = new Course();
Course c2 = new Course("MATH333",CourseType.THEORY,4);
Course c3 = new Course("OOP","CMPS251",CourseType.THEORY,4);
c1.setChs(1);
c1.setCode("SEMI100");
c1.setTitle("Postgraduate Seminar");
c1.setType(CourseType.SEMINAR);
/*printing header of course
* Code Type CHs Title
*/
Course.printHeader();
//print all courses taking advantage of overriding toString method
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
//print number of courses
System.out.println("Total number of courses is "+Course.totNumOfCourses);
/*
* creating instructor objects. Must make use of constructors chaining: constructor calls another
*/
Instructor i1 = new Instructor();
Instructor i2 = new Instructor("Huda Imran",1234);
Instructor i3 = new Instructor("Riyad Asad", 6326,"r.asad@qu.edu.qa");
i1.setName("Moza Ibrahim");
i1.setEmploymentId(5555);
i1.setEmail("m.ibra@qu.edu.qa");
/*printing header of Instructor
*
*/
Instructor.printHeader();
//print all instructors taking advantage of overriding toString method
System.out.println(i1);
System.out.println(i2);
System.out.println(i3);
//print number of instructors
System.out.println("Total number of courses is "+Instructor.totNumOfInstructors);
}
}
package hw1;
public class Runner {
public static void main(String[] args) {
/*print top header
ID Name Gender Age CH Academic Year
*/
Student.printHeader();
/* Creates a student and prints his info.
* Parameters here are: Name, age, number of courses enrolled in,
* academic year, and gender.
* Pay attention that the ID is auto generated and does not have a setter.
* valid age is [1-100] otherwise, it is set to 1
* valid academicYear is [1-10] otherwise, it is set to 1
* valid numEnrolledCourses is [1-9] otherwise, it is set to 0
*/
//You must make this constructor call the empty constructor which sets the value of the id
Student s1 = new Student("Ahemd Ali", 20, 6, 2);
/*printStudentInfo() prints the ID, name, Age, Credit Hours, Academic year, and gender.
* credit hours is the number of courses the student is enrolled in * 3
*/
s1.printStudentInfo();
//Creates a second student and prints the students' info
//You must make this constructor call the constructor that takes all attributes but not the gender
Student s2 = new Student("Radwan Ameer", 23, 5, 6, Gender.MALE);
s2.printStudentInfo();
//Creates a third student and prints the students' info
Student s3 = new Student();
//sets the name of s3 to Aisha Fawaz
System.out.println("Setting the name of p3 to "Aisha Fawaz"");
s3.setName("Aisha Fawaz");
//Set number of enrolled courses for Aisha to 4
System.out.println("Setting number of enrolled courses of Aisha to 4");
s3.setNumEnrolledCourses(4);
/*printStudentInfo() for s3 */
s3.printStudentInfo();
//Set number of enrolled courses of Aisha to 10!
System.out.println("Set enrolled courses to 10!");
s3.setNumEnrolledCourses(10);
/*printStudentInfo() for s3 */
s3.printStudentInfo();
//Sets the age of Aisha to 19
System.out.println("Setting Aisha's age to 19");
s3.setAge(19);
//sets the gender of Aisha to Female
s3.setGender(Gender.FEMALE);
// printStudentInfo() for s3
s3.printStudentInfo();
/*checks if s1 and s3 having the same values for all of their corresponding attributes*/
System.out.println("s1.equals(s3)? "+s1.equals(s3));
//creates student object s4
Student s4 = new Student();
/*copies data of s1 to s4*/
s1.copy(s4);
System.out.println("s4 is a copy of s1");
/*checks if s1 and s4 having the same values for all of their corresponding attributes*/
System.out.println("s1.equals(s4)? "+s1.equals(s4));
/*creates a clone of s3 and returns its reference to be saved in s5.
* s5 is a clone of s3
*/
Student s5 = s3.clone();
System.out.println("s5 is a clone of s3");
/*checks if s3 and s5 having the same values for all of their corresponding attributes*/
System.out.println("s3.equals(s5)? "+s3.equals(s5));
/*compares s1 to s2 based on the value of the attribute id.
* if the value of id of s1 is less than the value of id of s2 the method returns -1,
* if the value of id of s1 is greater than the value of id of s2 the method returns 1,
* otherwise the two values of id are equal, it returns 0.
*/
switch(s1.compareTo(s2)) {
case -1: System.out.println("s1.id<s2.id");break;
case 1: System.out.println("s1.d>s2.id");break;
case 0: System.out.println("s1.id==s2.id");break;
}
//prints all students
System.out.println();
Student.printHeader();
s1.printStudentInfo();
s2.printStudentInfo();
s3.printStudentInfo();
s4.printStudentInfo();
s5.printStudentInfo();
System.out.println("ntotal number of students is: " + Student.totalNumOfStudents);
/*
* creating course objects. Must make use of constructors chaining: constructor calls another
* the course type can be THEORY,LAB,SEMINAR,SDP,TRAINING
*/
Course c1 = new Course();
Course c2 = new Course("MATH333",CourseType.THEORY,4);
Course c3 = new Course("OOP","CMPS251",CourseType.THEORY,4);
c1.setChs(1);
c1.setCode("SEMI100");
c1.setTitle("Postgraduate Seminar");
c1.setType(CourseType.SEMINAR);
/*printing header of course
* Code Type CHs Title
*/
Course.printHeader();
//print all courses taking advantage of overriding toString method
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
//print number of courses
System.out.println("Total number of courses is "+Course.totNumOfCourses);
/*
* creating instructor objects. Must make use of constructors chaining: constructor calls another
*/
Instructor i1 = new Instructor();
Instructor i2 = new Instructor("Huda Imran",1234);
Instructor i3 = new Instructor("Riyad Asad", 6326,"r.asad@qu.edu.qa");
i1.setName("Moza Ibrahim");
i1.setEmploymentId(5555);
i1.setEmail("m.ibra@qu.edu.qa");
/*printing header of Instructor
*
*/
Instructor.printHeader();
//print all instructors taking advantage of overriding toString method
System.out.println(i1);
System.out.println(i2);
System.out.println(i3);
//print number of instructors
System.out.println("Total number of courses is "+Instructor.totNumOfInstructors);
}
}
Assignment Details: 1. Import the attached project to Eclipse. 2. Add the needed classes to have
the Runner class executes without errors and without changing the code in the Runner class. 3.
Pay attention to the embedded comments in the Runner class. 4. Once done, the output should
look like that on the following:

More Related Content

PDF
package hw1-public class Runner { public static void main(String-- arg (1).pdf
PPTX
Structures in C.pptx
PPTX
OOPS 22-23 (1).pptx
PDF
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
PPTX
12Structures.pptx
PPTX
STRUCTURES IN C PROGRAMMING
PDF
Can someone help me with this code When I run it, it stops after th.pdf
PDF
Roadmap to Object Oriented Programming
package hw1-public class Runner { public static void main(String-- arg (1).pdf
Structures in C.pptx
OOPS 22-23 (1).pptx
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
12Structures.pptx
STRUCTURES IN C PROGRAMMING
Can someone help me with this code When I run it, it stops after th.pdf
Roadmap to Object Oriented Programming

Similar to the code is as the following- package hw1-public class Runner { public.pdf (20)

PDF
VIT351 Software Development VI Unit4
PDF
9608 Computer Science Cambridge International AS level Pre-Release May June p...
PPTX
Programming for problem solving-II(UNIT-2).pptx
PDF
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
PDF
java-programming.pdf
PDF
@author public class Person{   String sname, .pdf
PDF
Chapter15 structure
PPT
lecture10 introduction to Classes and Objects.ppt
PPT
Materi TIK Class dan Objects Data O-O-P.ppt
PDF
Answer using basic programming beginner knowledge pls...........Othe.pdf
PDF
The purpose of this C++ programming project is to allow the student .pdf
PDF
Java questionI am having issues returning the score sort in numeri.pdf
PPTX
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
PDF
This is my code but not complete, please complete my.pdf
PDF
Visual Programming Lacture Nine 9 Structure.pdf
PDF
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
PPTX
OOP-Lecture-05 (Constructor_Destructor).pptx
PDF
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
PPT
lecture10.ppt
PPT
lecture10.ppt fir class ibect fir c++ fr opps
VIT351 Software Development VI Unit4
9608 Computer Science Cambridge International AS level Pre-Release May June p...
Programming for problem solving-II(UNIT-2).pptx
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
java-programming.pdf
@author public class Person{   String sname, .pdf
Chapter15 structure
lecture10 introduction to Classes and Objects.ppt
Materi TIK Class dan Objects Data O-O-P.ppt
Answer using basic programming beginner knowledge pls...........Othe.pdf
The purpose of this C++ programming project is to allow the student .pdf
Java questionI am having issues returning the score sort in numeri.pdf
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
This is my code but not complete, please complete my.pdf
Visual Programming Lacture Nine 9 Structure.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
OOP-Lecture-05 (Constructor_Destructor).pptx
22 scheme OOPs with C++ BCS306B_module2.pdfmodule2.pdf
lecture10.ppt
lecture10.ppt fir class ibect fir c++ fr opps
Ad

More from arjunarasso (20)

PDF
The following account balances come from the records of Ourso Company-.pdf
PDF
The folldwing informotion pertalas to Qvestione 1416 - Panone amortize.pdf
PDF
The Fish Aquarium obtained funds from a bank and owes interest on a no.pdf
PDF
The first picture below is a lichen attached to a tree branch- Moss is.pdf
PDF
The first independent Variable is the method of instruction- Video Ins.pdf
PDF
The Endocrine System Materiats Objectuves - Haman torio roadd - Wilt d.pdf
PDF
The features in a model---- Are always functions of each other Keep th.pdf
PDF
The external rate of return is x--xternal rate of return (EROR) using.pdf
PDF
The fancy French Perfume Conpany recently had its secret formula divul.pdf
PDF
The events M- F- C- P and S are defined as Male- Female- Coca Cola- Pe.pdf
PDF
The evolutionary tree below indicates the relationships among differen.pdf
PDF
the espected refum tir aok x ib T The sepected reteh for asa y is 111.pdf
PDF
The Edge layer in IoT relates to the analytics and pre-processing serv.pdf
PDF
The Emergency Medical Treatment and Active Labor Act (EMTALA) prevents.pdf
PDF
The elasticity of demand for a good tends to increase if- Select one-.pdf
PDF
The economy of Singsville currently has $70-00 million worth of curren.pdf
PDF
The economy of Nickeltown currently has a level of M1 equal to $40-00.pdf
PDF
The due dates refed the need for the order to be at ta next cperaton-.pdf
PDF
The disadvantage of the IRR method is that a- the IRR requires long-.pdf
PDF
The Director of Nursing of the hospital asks the staff development coo.pdf
The following account balances come from the records of Ourso Company-.pdf
The folldwing informotion pertalas to Qvestione 1416 - Panone amortize.pdf
The Fish Aquarium obtained funds from a bank and owes interest on a no.pdf
The first picture below is a lichen attached to a tree branch- Moss is.pdf
The first independent Variable is the method of instruction- Video Ins.pdf
The Endocrine System Materiats Objectuves - Haman torio roadd - Wilt d.pdf
The features in a model---- Are always functions of each other Keep th.pdf
The external rate of return is x--xternal rate of return (EROR) using.pdf
The fancy French Perfume Conpany recently had its secret formula divul.pdf
The events M- F- C- P and S are defined as Male- Female- Coca Cola- Pe.pdf
The evolutionary tree below indicates the relationships among differen.pdf
the espected refum tir aok x ib T The sepected reteh for asa y is 111.pdf
The Edge layer in IoT relates to the analytics and pre-processing serv.pdf
The Emergency Medical Treatment and Active Labor Act (EMTALA) prevents.pdf
The elasticity of demand for a good tends to increase if- Select one-.pdf
The economy of Singsville currently has $70-00 million worth of curren.pdf
The economy of Nickeltown currently has a level of M1 equal to $40-00.pdf
The due dates refed the need for the order to be at ta next cperaton-.pdf
The disadvantage of the IRR method is that a- the IRR requires long-.pdf
The Director of Nursing of the hospital asks the staff development coo.pdf
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Classroom Observation Tools for Teachers
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Anesthesia in Laparoscopic Surgery in India
202450812 BayCHI UCSC-SV 20250812 v17.pptx
O7-L3 Supply Chain Operations - ICLT Program
Computing-Curriculum for Schools in Ghana
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Microbial diseases, their pathogenesis and prophylaxis
Supply Chain Operations Speaking Notes -ICLT Program
Orientation - ARALprogram of Deped to the Parents.pptx
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
GDM (1) (1).pptx small presentation for students
Classroom Observation Tools for Teachers
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

the code is as the following- package hw1-public class Runner { public.pdf

  • 1. the code is as the following: package hw1; public class Runner { public static void main(String[] args) { /*print top header ID Name Gender Age CH Academic Year */ Student.printHeader(); /* Creates a student and prints his info. * Parameters here are: Name, age, number of courses enrolled in, * academic year, and gender. * Pay attention that the ID is auto generated and does not have a setter. * valid age is [1-100] otherwise, it is set to 1 * valid academicYear is [1-10] otherwise, it is set to 1 * valid numEnrolledCourses is [1-9] otherwise, it is set to 0 */ //You must make this constructor call the empty constructor which sets the value of the id Student s1 = new Student("Ahemd Ali", 20, 6, 2); /*printStudentInfo() prints the ID, name, Age, Credit Hours, Academic year, and gender. * credit hours is the number of courses the student is enrolled in * 3 */
  • 2. s1.printStudentInfo(); //Creates a second student and prints the students' info //You must make this constructor call the constructor that takes all attributes but not the gender Student s2 = new Student("Radwan Ameer", 23, 5, 6, Gender.MALE); s2.printStudentInfo(); //Creates a third student and prints the students' info Student s3 = new Student(); //sets the name of s3 to Aisha Fawaz System.out.println("Setting the name of p3 to "Aisha Fawaz""); s3.setName("Aisha Fawaz"); //Set number of enrolled courses for Aisha to 4 System.out.println("Setting number of enrolled courses of Aisha to 4"); s3.setNumEnrolledCourses(4); /*printStudentInfo() for s3 */ s3.printStudentInfo(); //Set number of enrolled courses of Aisha to 10! System.out.println("Set enrolled courses to 10!"); s3.setNumEnrolledCourses(10); /*printStudentInfo() for s3 */ s3.printStudentInfo(); //Sets the age of Aisha to 19
  • 3. System.out.println("Setting Aisha's age to 19"); s3.setAge(19); //sets the gender of Aisha to Female s3.setGender(Gender.FEMALE); // printStudentInfo() for s3 s3.printStudentInfo(); /*checks if s1 and s3 having the same values for all of their corresponding attributes*/ System.out.println("s1.equals(s3)? "+s1.equals(s3)); //creates student object s4 Student s4 = new Student(); /*copies data of s1 to s4*/ s1.copy(s4); System.out.println("s4 is a copy of s1"); /*checks if s1 and s4 having the same values for all of their corresponding attributes*/ System.out.println("s1.equals(s4)? "+s1.equals(s4)); /*creates a clone of s3 and returns its reference to be saved in s5. * s5 is a clone of s3 */ Student s5 = s3.clone(); System.out.println("s5 is a clone of s3"); /*checks if s3 and s5 having the same values for all of their corresponding attributes*/ System.out.println("s3.equals(s5)? "+s3.equals(s5)); /*compares s1 to s2 based on the value of the attribute id.
  • 4. * if the value of id of s1 is less than the value of id of s2 the method returns -1, * if the value of id of s1 is greater than the value of id of s2 the method returns 1, * otherwise the two values of id are equal, it returns 0. */ switch(s1.compareTo(s2)) { case -1: System.out.println("s1.id<s2.id");break; case 1: System.out.println("s1.d>s2.id");break; case 0: System.out.println("s1.id==s2.id");break; } //prints all students System.out.println(); Student.printHeader(); s1.printStudentInfo(); s2.printStudentInfo(); s3.printStudentInfo(); s4.printStudentInfo(); s5.printStudentInfo(); System.out.println("ntotal number of students is: " + Student.totalNumOfStudents); /* * creating course objects. Must make use of constructors chaining: constructor calls another * the course type can be THEORY,LAB,SEMINAR,SDP,TRAINING */ Course c1 = new Course();
  • 5. Course c2 = new Course("MATH333",CourseType.THEORY,4); Course c3 = new Course("OOP","CMPS251",CourseType.THEORY,4); c1.setChs(1); c1.setCode("SEMI100"); c1.setTitle("Postgraduate Seminar"); c1.setType(CourseType.SEMINAR); /*printing header of course * Code Type CHs Title */ Course.printHeader(); //print all courses taking advantage of overriding toString method System.out.println(c1); System.out.println(c2); System.out.println(c3); //print number of courses System.out.println("Total number of courses is "+Course.totNumOfCourses); /* * creating instructor objects. Must make use of constructors chaining: constructor calls another */ Instructor i1 = new Instructor(); Instructor i2 = new Instructor("Huda Imran",1234);
  • 6. Instructor i3 = new Instructor("Riyad Asad", 6326,"r.asad@qu.edu.qa"); i1.setName("Moza Ibrahim"); i1.setEmploymentId(5555); i1.setEmail("m.ibra@qu.edu.qa"); /*printing header of Instructor * */ Instructor.printHeader(); //print all instructors taking advantage of overriding toString method System.out.println(i1); System.out.println(i2); System.out.println(i3); //print number of instructors System.out.println("Total number of courses is "+Instructor.totNumOfInstructors); } } package hw1; public class Runner { public static void main(String[] args) { /*print top header ID Name Gender Age CH Academic Year
  • 7. */ Student.printHeader(); /* Creates a student and prints his info. * Parameters here are: Name, age, number of courses enrolled in, * academic year, and gender. * Pay attention that the ID is auto generated and does not have a setter. * valid age is [1-100] otherwise, it is set to 1 * valid academicYear is [1-10] otherwise, it is set to 1 * valid numEnrolledCourses is [1-9] otherwise, it is set to 0 */ //You must make this constructor call the empty constructor which sets the value of the id Student s1 = new Student("Ahemd Ali", 20, 6, 2); /*printStudentInfo() prints the ID, name, Age, Credit Hours, Academic year, and gender. * credit hours is the number of courses the student is enrolled in * 3 */ s1.printStudentInfo(); //Creates a second student and prints the students' info //You must make this constructor call the constructor that takes all attributes but not the gender Student s2 = new Student("Radwan Ameer", 23, 5, 6, Gender.MALE); s2.printStudentInfo(); //Creates a third student and prints the students' info
  • 8. Student s3 = new Student(); //sets the name of s3 to Aisha Fawaz System.out.println("Setting the name of p3 to "Aisha Fawaz""); s3.setName("Aisha Fawaz"); //Set number of enrolled courses for Aisha to 4 System.out.println("Setting number of enrolled courses of Aisha to 4"); s3.setNumEnrolledCourses(4); /*printStudentInfo() for s3 */ s3.printStudentInfo(); //Set number of enrolled courses of Aisha to 10! System.out.println("Set enrolled courses to 10!"); s3.setNumEnrolledCourses(10); /*printStudentInfo() for s3 */ s3.printStudentInfo(); //Sets the age of Aisha to 19 System.out.println("Setting Aisha's age to 19"); s3.setAge(19); //sets the gender of Aisha to Female s3.setGender(Gender.FEMALE); // printStudentInfo() for s3 s3.printStudentInfo(); /*checks if s1 and s3 having the same values for all of their corresponding attributes*/
  • 9. System.out.println("s1.equals(s3)? "+s1.equals(s3)); //creates student object s4 Student s4 = new Student(); /*copies data of s1 to s4*/ s1.copy(s4); System.out.println("s4 is a copy of s1"); /*checks if s1 and s4 having the same values for all of their corresponding attributes*/ System.out.println("s1.equals(s4)? "+s1.equals(s4)); /*creates a clone of s3 and returns its reference to be saved in s5. * s5 is a clone of s3 */ Student s5 = s3.clone(); System.out.println("s5 is a clone of s3"); /*checks if s3 and s5 having the same values for all of their corresponding attributes*/ System.out.println("s3.equals(s5)? "+s3.equals(s5)); /*compares s1 to s2 based on the value of the attribute id. * if the value of id of s1 is less than the value of id of s2 the method returns -1, * if the value of id of s1 is greater than the value of id of s2 the method returns 1, * otherwise the two values of id are equal, it returns 0. */ switch(s1.compareTo(s2)) { case -1: System.out.println("s1.id<s2.id");break; case 1: System.out.println("s1.d>s2.id");break;
  • 10. case 0: System.out.println("s1.id==s2.id");break; } //prints all students System.out.println(); Student.printHeader(); s1.printStudentInfo(); s2.printStudentInfo(); s3.printStudentInfo(); s4.printStudentInfo(); s5.printStudentInfo(); System.out.println("ntotal number of students is: " + Student.totalNumOfStudents); /* * creating course objects. Must make use of constructors chaining: constructor calls another * the course type can be THEORY,LAB,SEMINAR,SDP,TRAINING */ Course c1 = new Course(); Course c2 = new Course("MATH333",CourseType.THEORY,4); Course c3 = new Course("OOP","CMPS251",CourseType.THEORY,4); c1.setChs(1); c1.setCode("SEMI100"); c1.setTitle("Postgraduate Seminar"); c1.setType(CourseType.SEMINAR); /*printing header of course
  • 11. * Code Type CHs Title */ Course.printHeader(); //print all courses taking advantage of overriding toString method System.out.println(c1); System.out.println(c2); System.out.println(c3); //print number of courses System.out.println("Total number of courses is "+Course.totNumOfCourses); /* * creating instructor objects. Must make use of constructors chaining: constructor calls another */ Instructor i1 = new Instructor(); Instructor i2 = new Instructor("Huda Imran",1234); Instructor i3 = new Instructor("Riyad Asad", 6326,"r.asad@qu.edu.qa"); i1.setName("Moza Ibrahim"); i1.setEmploymentId(5555); i1.setEmail("m.ibra@qu.edu.qa"); /*printing header of Instructor * */
  • 12. Instructor.printHeader(); //print all instructors taking advantage of overriding toString method System.out.println(i1); System.out.println(i2); System.out.println(i3); //print number of instructors System.out.println("Total number of courses is "+Instructor.totNumOfInstructors); } } Assignment Details: 1. Import the attached project to Eclipse. 2. Add the needed classes to have the Runner class executes without errors and without changing the code in the Runner class. 3. Pay attention to the embedded comments in the Runner class. 4. Once done, the output should look like that on the following: