SlideShare a Scribd company logo
1 of 5
Imam University | CCIS | Vice Deanery of Development and Quality
Doc. No. 006-01-20140514
Page 1 of 5
Al Imam Mohammad Ibn Saud Islamic University
College of Computer and Information Sciences
Computer Science Department
Course Title: Computer Programming II
Course Code: CS141
Course Instructor: Dr. Adel Ammar, Dr. Ashraf Shahin, Dr. Yassin Daada, Dr.
Aram Alsedrani, Mse. Ebtesam Alobood, Mse. Mai
Alammar, Mse. Hessa Alawad, Mse. Shahad Alqefari,
Ahmed Khorsi
Exam: Midterm Exam 1
Semester: Fall 2017
Date: October31, 2017
Duration: 1 hour
Marks: 15
Privileges: ☐ Open Book
☐ Calculator Permitted
☐ Open Notes
☐ Laptop Permitted
Student Name (in English):
Student ID: Model Answer
Section No.:
Instructions:
1. Answer 3 questions; there are 3 questions in 5 pages.
2. Write your name on each page of the exam paper.
3. Write your answers directly on the question sheets. Use the backs of the question
pages for rough work or if you need extra space for your answer.
4. If information appears to be missing from a question, make a reasonable
assumption, state your assumption, and proceed.
5. No questions will be answered by the invigilator(s) during the exam period.
Question Student Marks Question Marks
1 4
2 4
3 7
Total 15
Imam University | CCIS | Vice Deanery of Development and Quality
Doc. No. 006-01-20140514
Page 2 of 5
Student Name (in English): __________________________________________ Student ID: _____________________
Question 1: To be answered in (10) Minutes [ ] / 4 Marks
Write the implementation of the class WordType
public class WordType // 0.5 mark
{
private final String name; // 0.5 mark
public WordType(String name) // 0.5 mark
{
if (!name.equals("Noun") && !name.equals("Verb")) // 0.75 mark
throw new IllegalArgumentException("The subject must be a noun");
this.name=name; // 0.5 mark
}
public String getName()
{
return name;
}
public Boolean isNoun() // 0.5 mark
{
return name.equals("Noun"); // 0.75 mark
}
}
Imam University | CCIS | Vice Deanery of Development and Quality
Doc. No. 006-01-20140514
Page 3 of 5
Question 2: To be answered in (10) Minutes [ ] / 4 Marks
Write the implementation of the class Word
public class Word {
private final String value; // 0.25 mark
private WordType type; // 0.25 mark
private static int numberOfVerbs; // 0.25 mark
public Word(String value, WordType type) { // 0.25 mark
this.value = value; // 0.25 mark
this.type = type; // 0.25 mark
if (!type.isNoun()) { // 0.25 mark
++numberOfVerbs; // 0.25 mark
}
}
public void setType(WordType type) { // 0.25 mark
if(type.isNoun() && !this.type.isNoun())
numberOfVerbs--;
if(!type.isNoun() && this.type.isNoun())
numberOfVerbs++;
this.type = type; // 0.25 mark
}
public String getValue() { // 0.25 mark
return value;
}
public WordType getType() { // 0.25 mark
return type;
}
public static int getNumberOfVerbs() { // 0.25 mark
return numberOfVerbs;
}
Imam University | CCIS | Vice Deanery of Development and Quality
Doc. No. 006-01-20140514
Page 4 of 5
public String toString() { // 0.25 mark
return String.format("%s / %s", value, type.getName()); // 0.5 mark
}
}
Question 3: To be answered in (30) Minutes [ ] / 8 Marks
Write the implementation of the class Phrase:
public class Phrase {
private Word subject; // 0.25 mark
private Word verb; // 0.25 mark
private Word object; // 0.25 mark
public Phrase(Word subject, Word verb, Word object) { // 0.25 mark
if (!subject.getType().isNoun()) // 0.75 mark
throw new IllegalArgumentException("The subject must be a noun"); // 0.25 mark
this.subject = subject; // 0.25 mark
this.verb = verb; // 0.25 mark
this.object = object; // 0.25 mark
}
public void setSubject(Word subject) { // 0.25 mark
if (!subject.getType().isNoun())
throw new IllegalArgumentException("The subject must be a noun");
this.subject = subject; // 0.25 mark
}
public void setVerb(Word verb) { // 0.25 mark
this.verb = verb; // 0.25 mark
}
public void setObject(Word object) { // 0.25 mark
this.object = object; // 0.25 mark
}
public Word getSubject() { // 0.25 mark
return subject; // 0.25 mark
Imam University | CCIS | Vice Deanery of Development and Quality
Doc. No. 006-01-20140514
Page 5 of 5
}
public Word getVerb() { // 0.25 mark
return verb; // 0.25 mark
}
public Word getObject() { // 0.25 mark
return object; // 0.25 mark
}
public String toString() { // 0.25 mark
return String.format("%s %s %s", subject.getValue(), verb.getValue(), object.getValue());
// 1 mark
}
}

More Related Content

Similar to Cs141 mid1-2017-fall-solution2

Cs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answerCs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answerFahadaio
 
Exam Technique - please the examiner
Exam Technique - please the examinerExam Technique - please the examiner
Exam Technique - please the examinerDavid Harris
 
Csc1100 elements of programming (revised july 2014) 120lh-2-student
Csc1100 elements of  programming (revised july 2014) 120lh-2-studentCsc1100 elements of  programming (revised july 2014) 120lh-2-student
Csc1100 elements of programming (revised july 2014) 120lh-2-studentIIUM
 
Cs141 mid termexam v3
Cs141 mid termexam v3Cs141 mid termexam v3
Cs141 mid termexam v3Fahadaio
 
Qwizdom answer key
Qwizdom answer keyQwizdom answer key
Qwizdom answer keyroxiehill
 
Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Gurpreet singh
 
1-Lec - Introduction and Course Objectives.ppt
1-Lec - Introduction and Course Objectives.ppt1-Lec - Introduction and Course Objectives.ppt
1-Lec - Introduction and Course Objectives.pptAqeelAbbas51
 

Similar to Cs141 mid1-2017-fall-solution2 (8)

Cs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answerCs141 mid termexam2_v1answer
Cs141 mid termexam2_v1answer
 
Exam Technique - please the examiner
Exam Technique - please the examinerExam Technique - please the examiner
Exam Technique - please the examiner
 
Csc1100 elements of programming (revised july 2014) 120lh-2-student
Csc1100 elements of  programming (revised july 2014) 120lh-2-studentCsc1100 elements of  programming (revised july 2014) 120lh-2-student
Csc1100 elements of programming (revised july 2014) 120lh-2-student
 
Cs141 mid termexam v3
Cs141 mid termexam v3Cs141 mid termexam v3
Cs141 mid termexam v3
 
Qwizdom answer key
Qwizdom answer keyQwizdom answer key
Qwizdom answer key
 
Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)
 
1-Lec - Introduction and Course Objectives.ppt
1-Lec - Introduction and Course Objectives.ppt1-Lec - Introduction and Course Objectives.ppt
1-Lec - Introduction and Course Objectives.ppt
 
Lecture01
Lecture01Lecture01
Lecture01
 

More from Fahadaio

Quiz2 cs141-1-17
Quiz2 cs141-1-17Quiz2 cs141-1-17
Quiz2 cs141-1-17Fahadaio
 
Quiz1 cs141-1-17
Quiz1 cs141-1-17Quiz1 cs141-1-17
Quiz1 cs141-1-17Fahadaio
 
Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2Fahadaio
 
Cs141 term project
Cs141 term projectCs141 term project
Cs141 term projectFahadaio
 
Cs141 mid termexam v5_solution
Cs141 mid termexam v5_solutionCs141 mid termexam v5_solution
Cs141 mid termexam v5_solutionFahadaio
 
Cs141 mid termexam v1
Cs141 mid termexam v1Cs141 mid termexam v1
Cs141 mid termexam v1Fahadaio
 

More from Fahadaio (6)

Quiz2 cs141-1-17
Quiz2 cs141-1-17Quiz2 cs141-1-17
Quiz2 cs141-1-17
 
Quiz1 cs141-1-17
Quiz1 cs141-1-17Quiz1 cs141-1-17
Quiz1 cs141-1-17
 
Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2Cs141 mid1-2017-fall v2
Cs141 mid1-2017-fall v2
 
Cs141 term project
Cs141 term projectCs141 term project
Cs141 term project
 
Cs141 mid termexam v5_solution
Cs141 mid termexam v5_solutionCs141 mid termexam v5_solution
Cs141 mid termexam v5_solution
 
Cs141 mid termexam v1
Cs141 mid termexam v1Cs141 mid termexam v1
Cs141 mid termexam v1
 

Recently uploaded

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 

Recently uploaded (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 

Cs141 mid1-2017-fall-solution2

  • 1. Imam University | CCIS | Vice Deanery of Development and Quality Doc. No. 006-01-20140514 Page 1 of 5 Al Imam Mohammad Ibn Saud Islamic University College of Computer and Information Sciences Computer Science Department Course Title: Computer Programming II Course Code: CS141 Course Instructor: Dr. Adel Ammar, Dr. Ashraf Shahin, Dr. Yassin Daada, Dr. Aram Alsedrani, Mse. Ebtesam Alobood, Mse. Mai Alammar, Mse. Hessa Alawad, Mse. Shahad Alqefari, Ahmed Khorsi Exam: Midterm Exam 1 Semester: Fall 2017 Date: October31, 2017 Duration: 1 hour Marks: 15 Privileges: ☐ Open Book ☐ Calculator Permitted ☐ Open Notes ☐ Laptop Permitted Student Name (in English): Student ID: Model Answer Section No.: Instructions: 1. Answer 3 questions; there are 3 questions in 5 pages. 2. Write your name on each page of the exam paper. 3. Write your answers directly on the question sheets. Use the backs of the question pages for rough work or if you need extra space for your answer. 4. If information appears to be missing from a question, make a reasonable assumption, state your assumption, and proceed. 5. No questions will be answered by the invigilator(s) during the exam period. Question Student Marks Question Marks 1 4 2 4 3 7 Total 15
  • 2. Imam University | CCIS | Vice Deanery of Development and Quality Doc. No. 006-01-20140514 Page 2 of 5 Student Name (in English): __________________________________________ Student ID: _____________________ Question 1: To be answered in (10) Minutes [ ] / 4 Marks Write the implementation of the class WordType public class WordType // 0.5 mark { private final String name; // 0.5 mark public WordType(String name) // 0.5 mark { if (!name.equals("Noun") && !name.equals("Verb")) // 0.75 mark throw new IllegalArgumentException("The subject must be a noun"); this.name=name; // 0.5 mark } public String getName() { return name; } public Boolean isNoun() // 0.5 mark { return name.equals("Noun"); // 0.75 mark } }
  • 3. Imam University | CCIS | Vice Deanery of Development and Quality Doc. No. 006-01-20140514 Page 3 of 5 Question 2: To be answered in (10) Minutes [ ] / 4 Marks Write the implementation of the class Word public class Word { private final String value; // 0.25 mark private WordType type; // 0.25 mark private static int numberOfVerbs; // 0.25 mark public Word(String value, WordType type) { // 0.25 mark this.value = value; // 0.25 mark this.type = type; // 0.25 mark if (!type.isNoun()) { // 0.25 mark ++numberOfVerbs; // 0.25 mark } } public void setType(WordType type) { // 0.25 mark if(type.isNoun() && !this.type.isNoun()) numberOfVerbs--; if(!type.isNoun() && this.type.isNoun()) numberOfVerbs++; this.type = type; // 0.25 mark } public String getValue() { // 0.25 mark return value; } public WordType getType() { // 0.25 mark return type; } public static int getNumberOfVerbs() { // 0.25 mark return numberOfVerbs; }
  • 4. Imam University | CCIS | Vice Deanery of Development and Quality Doc. No. 006-01-20140514 Page 4 of 5 public String toString() { // 0.25 mark return String.format("%s / %s", value, type.getName()); // 0.5 mark } } Question 3: To be answered in (30) Minutes [ ] / 8 Marks Write the implementation of the class Phrase: public class Phrase { private Word subject; // 0.25 mark private Word verb; // 0.25 mark private Word object; // 0.25 mark public Phrase(Word subject, Word verb, Word object) { // 0.25 mark if (!subject.getType().isNoun()) // 0.75 mark throw new IllegalArgumentException("The subject must be a noun"); // 0.25 mark this.subject = subject; // 0.25 mark this.verb = verb; // 0.25 mark this.object = object; // 0.25 mark } public void setSubject(Word subject) { // 0.25 mark if (!subject.getType().isNoun()) throw new IllegalArgumentException("The subject must be a noun"); this.subject = subject; // 0.25 mark } public void setVerb(Word verb) { // 0.25 mark this.verb = verb; // 0.25 mark } public void setObject(Word object) { // 0.25 mark this.object = object; // 0.25 mark } public Word getSubject() { // 0.25 mark return subject; // 0.25 mark
  • 5. Imam University | CCIS | Vice Deanery of Development and Quality Doc. No. 006-01-20140514 Page 5 of 5 } public Word getVerb() { // 0.25 mark return verb; // 0.25 mark } public Word getObject() { // 0.25 mark return object; // 0.25 mark } public String toString() { // 0.25 mark return String.format("%s %s %s", subject.getValue(), verb.getValue(), object.getValue()); // 1 mark } }