منتديات طلاب الجامعة العربية المفتوحة aoua.com

حلول واجبات الجامعة العربية المفتوحة 2012-2013 لجميع تخصصات الجامعة ولجميع فروع الجامعة حلول واجبات – مشاريع تخرج – ملخصات هامة http://helper.123.st/ 00966542495275 smsm.hamdy66@yahoo.com حلول مضمونة وغير مكررة وغير متشابهة
 
الرئيسيةس .و .جبحـثالأعضاءالمجموعاتالتسجيلدخول

شاطر | 
 

 m255 tma01 حل واجب M255: Object-Oriented Programming with Java

اذهب الى الأسفل 
كاتب الموضوعرسالة
whatsapp::00966542495275
Admin


المساهمات : 1464
تاريخ التسجيل : 03/02/2012

مُساهمةموضوع: m255 tma01 حل واجب M255: Object-Oriented Programming with Java   الجمعة نوفمبر 23, 2012 4:02 am

1
Supplementary material for
M255: Object-Oriented Programming with Java
Tutor-Marked Assignment M255
Cut-Off Date: 08 December, 2012
Total Marks: 50
This TMA covers Units 1-6 and Units 9-10. This TMA consists of 3 questions.
Contents
Question 1 (10)…………………………………………………………………………2
Question 2 (20)…………………………………………………………………………2
Question 3 (20)…………………………………………………………………………3
Important
Enter your solutions to this TMA into a Solution Document. This document
must be readable in Word. If you are in any doubt, try reading your document using
WordViewer before submitting it to the e-TMAs system.
To avoid sending over-large files through the e-TMA system (something that can cause
problems to those marking your assignment) please:
• prepare your Solution Document using Word if you have it;
• avoid sending an RTF document;
• do not copy screen shots, use copy and paste
Plagiarism Warning:
As per AOU rules and regulations, all students are required to submit their own TMA work and
avoid plagiarism. The AOU has implemented sophisticated techniques for plagiarism detection.
You must provide all references in case you use and quote another person's work in your TMA.
You will be penalized for any act of plagiarism as per the AOU's rules and regulations.
Declaration of No Plagiarism by Student (to be signed and submitted by student with TMA
work):
I hereby declare that this submitted TMA work is a result of my own efforts and I have not
plagiarized any other person's work. I have provided all references of information that I have
used and quoted in my TMA work.
Name of Student:………………………………..
Signature:…………………………………………...
Date:……………………………………………………
Arab Open University
2
M255-TMA Cut-off date: 08 Dec. 2012
Question One: [10 marks]
(i) Consider this code:
HoverFrog hoverFrog1 = new HoverFrog();
HoverFrog hoverFrog2 = new HoverFrog();
HoverFrog hoverFrog3 = hoverFrog1;
How many objects exist after this code has been executed? Explain your answer.
[2 marks ]
(ii) Write a public method to be added to the Frog class that causes the receiver Frog object to be
given the same position as the argument which is also a Frog object. The method signature is
samePositionAs(Frog), and it does not return an answer. Your method should include a
comment and the method heading. [4 marks]
(iii) Assuming that hoverFrog1 and frog1 reference objects of type HoverFrog and Frog
respectively, explain what happens from the point at which this message-send is executed
through to the result of the message-send: [4 marks]
hoverFrog1.samePositionAs(frog1);
Question 2: [20 marks]
(i) Danceable is an interface which specifies two methods with the signatures
pirouette(int) and prepareToDance(). Neither method returns an answer. Write
the Danceable interface. [3 marks]
(ii) Write the header of DanceableHoverFrog which is a subclass of HoverFrog that
implements the Danceable interface. The new class has the following methods:
[2 marks]
(a) Write the constructor of the class DanceableHoverFrog which initializes the inherited
attributes from superclass. [2 marks]
(b) Implement the method pirouette(n) as follows: [5 marks]
When sent a message of the form pirouette(3), an instance of DanceableHoverFrog
executes the number of pirouettes indicated by the message’s argument. Each pirouette consists
of hovering up by 1, moving to the left, hovering down by 1, and moving to the right.
(c) Implement the method prepareToDance() as follows: [6 marks]
When sent a prepareToDance() message an instance of DanceableHoverFrog goes directly
to height 3 and moves one stone towards stone 5 before returning directly to ground level again.
This is repeated until it is at stone 5.
(iii) Interfaces and superclasses are both mechanisms for specifying common behavior. In two or
three sentences explain the differences between these two approaches.
[2 marks]
3
Question 3: [20 marks]
The following table shows area codes and the animals that have been sighted in these areas.
Such tables are implemented and managed by instances of a class called GameKeeper.
(i) The class GameKeeper needs a single private instance variable called animalMap.
Write the declaration for animalMap, it should be declared to be of a suitable interface
type to hold a map whose keys are characters and whose values are sets of strings. There
is no need to hold the data in any particular order. Note that the wrapper class for type
char is Character. [2 marks]
(ii) Write a zero-argument constructor for the GameKeeper class that creates an empty
instance of a suitable class that implements a map and assigns it to animalMap.
[3 marks]
(iii) Write an instance method for the GameKeeper class called addAnimalEntry(). The
method should fill the first two rows on animalMap where the code area is ‘A and ‘B’.
[7 marks]
(iv) The GameKeeper class needs a second instance method called
findEcoDiversity(int y) which takes an integer argument and returns a set of
strings.
The method should iterate over each of the keys in animalMap. In each case where the
number of strings in the corresponding value is greater than the threshold value indicated
by the integer argument to the method, a message should be printed to the standard output
as follows:
Area code X has more than Y kinds of animals
(where X and Y are filled in appropriately)
Finally, the method should return as message reply the last set of strings found (where the
number of strings is greater than the threshold) or an empty list, if none were found.
[8 marks]

_________________
خدمات مجانية – حلول واجبات الجامعة العربية المفتوحة
لجميع تخصصات الجامعة ولجميع فروع الجامعة
حلول واجبات – مشاريع تخرج – ملخصات هامة

حلول واجبات الجامعة العربية المفتوحة لجميع تخصصات الجامعة ولجميع فروع الجامعة حلول واجبات – مشاريع تخرج – ملخصات هامة whatsapp :00966542495275
smsm.hamdy66@yahoo.com
حلول مضمونة وغير مكررة وغير متشابهة لجميع واجبات الجامعة
متوفرمدرسين ومدرسات لجميع المواد والتخصصات
KSA-Kuwait-Bahrain-Oman-Jordon-Lebanon-Egypt
قسم خاص لواجبا ت التربية لجميع التخصصات ولجميع المستويات
الرجوع الى أعلى الصفحة اذهب الى الأسفل
معاينة صفحة البيانات الشخصي للعضو http://helper.123.st
 
m255 tma01 حل واجب M255: Object-Oriented Programming with Java
الرجوع الى أعلى الصفحة 
صفحة 1 من اصل 1
 مواضيع مماثلة
-
» ~-~ الآن يمكنك تجربة ألعاب java على الكمبيوتر قبل تثبيتها على الجوال~-~

صلاحيات هذا المنتدى:لاتستطيع الرد على المواضيع في هذا المنتدى
منتديات طلاب الجامعة العربية المفتوحة aoua.com :: حل واجبات جامعة AOU :: حل واجبات الجامعة-
انتقل الى: