حل واجبات الجامعة العربية المفتوحة whats : 00966542495275

أهلا وسهلا بك إلى منتدي حل واجبات الجامعة العربية المفتوحة || 00966542495275
 
الرئيسيةاليوميةس .و .جبحـثالأعضاءالمجموعاتالتسجيلدخول

شاطر | 
 

 حل واجب M257

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


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

مُساهمةموضوع: حل واجب M257   الأحد مارس 16, 2014 7:02 pm

M257 TMA Spring 13-14 Page 1
Faculty of Computer Studies
Course Code: M257
Course Title: Putting Java to Work
Tutor Marked Assignment – Spring 13-14
Cut-off Date May 6, 2014 Total Marks:100 converted to
be out of 20
Contents:
TMA Instructions …………………….………… 2
Question 1 ……………………………………… 3
Question 2 ……………………………………… 6
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:
M257 TMA Spring 13-14 Page 2
TMA Instructions
This TMA assesses your work on Units 1-7 of M257. The marks allocated to each part of a
question are indicated in the margin. The total marks for each question are shown at the
beginning of each question.
For TMA questions that require coding, a number of marks may be awarded for the style of your
Java code. This means that we expect you to be consistent and to follow good practice in the
naming of identifiers and layout
In all questions that require coding Question 1 Part 1 & Question 2, you should do the
following:
1- You should develop the required programs in NetBeans.
2- You must create ONE project for all TMA questions in one package, the default location for
NetBeans projects under Windows 7 are: Documents/NetBeansProjects.
You are required to create a Word file named M257_TMA_Spring13-14_ID_Name. Then you are
required to do the following:
Question1 Part 1: copy and paste the code and add one snap-shot for the results
Question1 Part 2: write the answers of the questions.
Question1 Part 1: copy and paste the code and add 3 snap-shots for the results
The TMA for the course has been uploaded to the LMS. You should start working on
it right away. Please note the following when working on the TMA:
• No group work is allowed for the TMA. Each student must submit his/her
own solution individually.
• Copying the answers from any source other than your own work will be
considered as plagiarism.
• Use your own words to answer essay questions.
• Read carefully the second page of the TMA for important instructions.
After you finish solving the TMA,You have 2 Submission's Links:
1- The Regular Submission Link: you need to submit to the regular submission link
a compressed file (e.g. zip file) which includes the following: your NetBeans project
folder (in Windows 7, you can find this under Documents/NetBeansProjects),
2- The Turnitin submission Link: You need to submit a document Word file
including all your answers to all questions according to the guidelines on the cover
page of the TMA.
M257 TMA Spring 13-14 Page 3
Question 1 [80 marks]
This assignment is an exercise in fundamental Java concepts such as: classes, constructors, methods,
composition, abstract, interfaces, basic control structure, HashMap collection handle reading from TXT
file and handle exceptions . This question includes two parts, each of which is simple if done according to
the specifications given in the exercise.
Part 1: Write the Java programs according to the following specifications: [60 marks]
Part 1.1 Develop an interface Colourful to the following specifications: [2 marks]
It includes one public method assignMyColour( String colour). When this method is
implemented, it should set the colour of its object by the given value as its argument.
Part 1.2 Develop a public class Point to the following specifications: [6 marks]
1) The class has two private instance variables: int x and y.
2) The class has a multi-argument constructor that sets the values of its instance
variables to the given values.
3) The class has a zero-argument constructor that sets the values of its instance variables
to their default values. It should invoke the multi-argument constructor.
4) The class has the getter and setter methods for the instance variables.
Part 1.3 Develop a public abstract class Shape to the following specifications: [8 marks]
1) The class implements the Colourful interface.
2) The class has one private instance variable: Point p1.
3) The class has a one-argument constructor that creates and sets the value of its
instance variable to the given value of p1.
4) The class has to override the Object’s toString() method in order to return a string with
representation of the Point instance variables as:
(x, y)
5) Implement any methods that are needed.
Part 1.4 Develop a public class Oval to the following specifications: [12 marks]
1) The class inherits the Shape class.
2) The class has the following private instance variables: width and height as an integer,
myColour as string, counterO as an integer which keeps one copy for all instantiated
objects of oval and counts their numbers.
3) The class has a multi-argument constructor that creates and sets the values of its
instance variables to the given values. It should invoke its super-class constructor.
Oval (Point p, int width, int height, String colourName)
4) The class has the getter and the setter methods for the private instance variables width,
height, counterO.
5) The class has to override the Object’s toString() method in order to return a string
representation of the Oval instance variables as:
The oval in (10 , 10) its width is 80 its height is 90 its colour is Red
6) Implement any methods that are needed.
Part 1.5 Develop a public class Rectangle to the following specifications: [12 marks]
1) The class inherits the Shape class.
2) The class has the following private instance variables: Point p2, myColour as string,
counterR as an integer which keeps one copy for all instantiated objects of rectangle and
counts their numbers.
M257 TMA Spring 13-14 Page 4
3) The class has a multi-argument constructor that creates and sets the values of its
instance variables to the given values. It should invoke its super-class constructor.
Rectangle (Point p1, Point p2, String colourName)
4) The class has the getter and the setter methods for the private instance variable
counterR.
5) The class has to override the Object’s toString() method in order to return a string
representation of the Rectangle instance variables as:
The Rectangle starts at (0 , 0) and ends at (100 , 100) its colour is green
7) Implement any methods that are needed.
Part 1.6 Develop a public class MyShapes to the following specifications: [10 marks]
1) The class has one private instance variable HashMap<String, Shape> myShapes,
which represents the collection of shapes from class Shape and its subclasses.
2) The class has a zero-argument constructor that creates its instance variable
myShapes.
3) The class has the method void addOval( String type, Oval oval). It creates the key of
the Oval object by concatenating its type by its counter, and then it adds the Oval object
into the myShapes collection.
4) The class has the method void addRectangle( String type, Rectangle rectangle). It
creates the key of the Rectangle object by concatenating its type by its counter, and then
it adds the Rectangle object into the myShapes collection.
5) The class has the method String showShapes(), which returns a string representation
for all shapes in the collection or a message “There are no shapes in the collection” if
the collection is empty.
6) Implement any methods that are needed.
Part 1.7 Develop a public class TestMain to the following specifications: [10 marks]
1) The class has a static main method.
2) The class instantiate the MyShapes class.
3) The class has to fill myShapes instance object by reading the values from the TXT file
("C:/Spring13-14Shapes.txt"), which is provided in the TMA folder.
4) It should check whether the type of the shape is Oval or Rectangle and then it should use
the corresponding methods that are needed to add the objects into the myShapes object.
5) The data includes the following
For Oval: the type of the object followed by the Point P1’s coordinates width, height and
colour.
For Rectangle: the type of the object followed by Points P1 and P2 coordinates, and its
colour.
6) Finally, it should display on the screen the shapes in myShapes and the number of
Rectangle and Oval objects.
7) Implement any methods that are needed.
M257 TMA Spring 13-14 Page 5
Part 2: answer All the following Questions regarding to above classes specifications:
[20 marks]
2.1- What if any the modifications are needed, if the following methods are added to the
Colourful Interface? Explain your answer. [2 marks]
void makeItRed();
void makeItGreen();
void makeItBlue();
2.2- How did you deal with the method public void assignMyColour(String colourName) in
each of the Shape, Oval and Rectangle classes? Explain your answer. [2 marks]
2.3- Is it legal to write the following statements in the TestMain class? Explain your answer.
Shape shape1;
Shape shape2= new Shape(); [2 marks]
2.4- What is the relationship between the following classes?
Point class and Shape class
Oval class and Shape class [2 marks]
2.5- How did you handle the Exceptions in TestMain class? What are the two methods to deal
with the exceptions in the Java Language? [5 marks]
2.6- Suppose that the first line in the TXT file ("C:/Spring13-14Shapes.txt") is updated as
Oval M 10 80 90 Red
What will happen? Explain the problem and express your solution to solve the problem and
implement it in the code. [5 marks]
2.7- Explain how to sort a Map in Java. You are required to explain the mechanism for sorting
Map in Java. Checkout the following links to help you make your answer. [2 marks]
http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html
http://docs.oracle.com/javase/6/docs/api/java/util/SortedMap.html
http://docs.oracle.com/javase/7/docs/api/java/util/SortedMap.html
http://docs.oracle.com/javase/tutorial/collections/interfaces/sorted-map.html
http://docs.oracle.com/javase/tutorial/collections/interfaces/sorted-map.html
M257 TMA Spring 13-14 Page 6
Question 2 [20 marks]
This assignment is an exercise on using and building GUI interfaces, writing event driven programs, along
with using flow control structures, and JOptionPane classes.
You are required to build a GUI interface MyFrameMain to be able to input the required
values to draw an oval or a rectangle, select the colour and the number of repeated
shapes. The GUI interface should appear as in Figure 1 below, according to the
following specifications:
• Set its size to 700x500.
• Set its title to your AOU-ID and your name.
• The frame has Border Layout. It consists of three main JPanels, North, Centre,
South
• The North JPanel, user can do the following:
 The user can draw the outline of an oval using the current colour. The
result is a circle or an ellipse that fits within the rectangle whose top lefthand
corner is specified by the first two arguments, whose width is given by
the third argument and whose height is specified by the final argument. The
values will be filled in using four JTextFields. The oval will be displayed
once the user clicks on Add Oval JButton.
 The user can draw the outline of the specified rectangle using the current
colour. The top left-hand corner of the rectangle is defined by a pair of x
and y-coordinates. The final two arguments give the width and height. The
values will be filled in using four JTextFields. The Rectangle will be
displayed once the user clicks on Add Rectangle JButton.
 The user can select one of the three colours using JRadioButton group.
Red is the default, with green and blue available as well.
 The user can select the number of repeated shapes up to 10 from the
JList. The code repeats drawing the shape many times by adding a fixed
number to the values of x and y to shift the position of the new shape.
 The user can draw the two shapes by filling the values of the two shapes
and then clicking on Add Both JButton
• The Centre JPanel is the drawing area where the required shapes will be
displayed.
• The South JPanel contains two JButtons
 Clear button which clears all values in all JTextFields once the user clicks
on it.
 Exit Button which terminates the program once the user clicks on it.
• An appropriate event listener should be used and the buttons should implement
the listener objects for all buttons.
• paint() and repaint() methods should be implemented to be invoked to draw the
shapes.
• The class should have a main method to instantiate the Frame.
More details are added in the figures below
M257 TMA Spring 13-14
The GUI interface MyFrameMain
Figure 1
Draw one Red Oval
Figure 2
Draw 3 Blue Oval
Figure 3
Draw 3 Red Rectangle
Figure 4
Page 7
M257 TMA Spring 13-14 Page 8
Drwa Both shapes
4 blue ovals and 4 blue rectangles
Figure 5
“End of the Assignment”

_________________

لتحميل ملف حل الواجب .docx  من خلال التسجيل في المنتدى أو التعريف بنفسك لمعاينة هذا الملف  


خدمات مجانية – حلول واجبات الجامعة العربية المفتوحة - حل واجب tma tma01
لجميع تخصصات الجامعة ولجميع فروع الجامعة
حلول واجبات – مشاريع تخرج – ملخصات هامة
http://solution.123.st
whatsapp::00966542495275
whatsapp::00966542495275

whatsapp::00966542495275
smsm.hamdy66@yahoo.com
حلول مضمونة وغير مكررة وغير متشابهة لجميع واجبات الجامعة
متوفرمدرسين ومدرسات لجميع المواد والتخصصات
KSA-Kuwait-Bahrain-Oman-Jordon-Lebanon-Egypt
الكويت-البحرين-عمان-الأردن-السعودية-لبنان-مصر
الرياض-الدمام-جدة-الأحساء-المدينة المنورة-جده-حائل-بيروت-المنامة-القاهرة-مسقط
pg ,h[fhj hg[hlum hguvfdm hgltj,pm - pg,g ,h[fhj hg[hlum hguvfdmhgltj,pm
http://solution.123.st
الرجوع الى أعلى الصفحة اذهب الى الأسفل
معاينة صفحة البيانات الشخصي للعضو http://solution.123.st
 
حل واجب M257
استعرض الموضوع السابق استعرض الموضوع التالي الرجوع الى أعلى الصفحة 
صفحة 1 من اصل 1

صلاحيات هذا المنتدى:لاتستطيع الرد على المواضيع في هذا المنتدى
حل واجبات الجامعة العربية المفتوحة whats : 00966542495275 :: حل واجبات الجامعة العربية المفتوحة 2018-2017 :: طلاب الجامعة-
انتقل الى: