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

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

@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
aplolomedicalstoremr
 
Chapter15 structure
Chapter15 structureChapter15 structure
Chapter15 structure
Deepak Singh
 
Answer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdfAnswer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdf
suresh640714
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
Rahul04August
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
forwardcom41
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdf
fashionbigchennai
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
arihantmum
 
lecture10.ppt fir class ibect fir c++ fr opps
lecture10.ppt fir class ibect fir c++ fr oppslecture10.ppt fir class ibect fir c++ fr opps
lecture10.ppt fir class ibect fir c++ fr opps
manomkpsg
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
arrowvisionoptics
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
anandshingavi23
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
herminaherman
 

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

VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4
 
9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...
 
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdfEasy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
 
java-programming.pdf
java-programming.pdfjava-programming.pdf
java-programming.pdf
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Chapter15 structure
Chapter15 structureChapter15 structure
Chapter15 structure
 
Answer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdfAnswer using basic programming beginner knowledge pls...........Othe.pdf
Answer using basic programming beginner knowledge pls...........Othe.pdf
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .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
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptxObject Oriented Programming using C++: Ch06 Objects and Classes.pptx
Object Oriented Programming using C++: Ch06 Objects and Classes.pptx
 
This is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdfThis is my code but not complete, please complete my.pdf
This is my code but not complete, please complete my.pdf
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
lecture10.ppt
lecture10.pptlecture10.ppt
lecture10.ppt
 
lecture10.ppt
lecture10.pptlecture10.ppt
lecture10.ppt
 
lecture10.ppt fir class ibect fir c++ fr opps
lecture10.ppt fir class ibect fir c++ fr oppslecture10.ppt fir class ibect fir c++ fr opps
lecture10.ppt fir class ibect fir c++ fr opps
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
yash shakya.pptx
yash shakya.pptxyash shakya.pptx
yash shakya.pptx
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
 

More from arjunarasso

More from arjunarasso (20)

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

Recently uploaded

Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
SaadHumayun7
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
17thcssbs2
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 

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: