Beruflich Dokumente
Kultur Dokumente
Game
beginTheGame()
player1,
player2
Player Strategy
Play() myStrategy calculateChoise()
myStrategy.calculateChoise()
At the creation of a teacher, we precise the teacher name and the all his/her teaching
hours.
We want to write a Java program that allow us to know : the teacher name (name()
method)? and his/her complement hours (ch() method)? and the sum that
he/she will take for his/her complement teaching hours (sum() method)?
1) Draw the inheritance diagram? Which classes are abstracts? Where the
methods must be implemented ?
2) Write the classes in Java?
الحاوٌة موصفة أٌضا ً بالمسافة التً ستقطعها .هذه المعلومة ٌتم تمرٌرها عند بناء الحاوٌة و كعدد صحٌح
من الكٌلومترات.
الحاوٌة ال ٌمكنها أن تضم إال عدد محدد من البضائع و التً تعتمد على كمٌة كاملة من البضائع التً ال ٌجب تعدٌها.
هذه الكمٌة ٌمكن تحدٌدها إما من خالل الوزن الكلً للبضائع أو من خالل الحجم الكلً للبضائع و ذلك حسب نوع النقل المستخدم.
نوع النقل ٌؤثر أٌضا ً على حساب تكلفة نقل الحاوٌة والذي ٌعتمد أٌضا ً على كمٌة البضائع ضمن الحاوٌة.
بالتالً فإننا نمٌز بٌن عدة أنماط من الحاوٌات حسب نوع وسٌلة النقل المستعملة .مع ذلك فإنه ٌمكننا أن نجد بعض الصفات المشتركة بٌن الحاوٌات و التً ٌجب
تحدٌدها.
األنماط المختلفة للحاوٌات و صفاتهم معطاة بالجدول التالً:
4ـ اكتبوا الصف Testو الذي ٌقوم بإنشاء غرض من الشركة و مجموعة بضائع و من ثم نطلب من
الشركة نقل جزء من هذه البضائع بشكل جوي مستعجل و جزء آخر بشكل بري.
بعد ذلك نطلب من الشركة حساب التكلفة النهائٌة.
ph.addTelephoneListener(am);
bob.listenToPhone(ph);
ph.ringPhone();
ph.answerPhone();
}
}
Interface
Of Listener
Source of Listener
events 1..*
Button
ActionListener List
MenuItem
actionPerformed TextField
AdjustementListener
scrollbar
adjustementValueChanged
ItemListener Checkbox
CheckboxMenuItem
itemStateChanged Choice
List
Soft Eng 3 - Damas - د. باسم قصٌبة 40
2009
Listeners of Components as
events sources of events
ComponentListener
Component
componentMoved
componentHidden
componentResized
componentShow
TextListener
TextComponent
textValueChanged
ContainerListener
Container
componentAdded
componentRemoved
Soft Eng 3 - Damas - د. باسم قصٌبة 41
2009
Listeners of Components as
events sources of events
FocusListener
Component
focusGained
focusLost
KeyListener
keyPressed
keyReleased Component
keyTyped
MouseMotionListener
Component
mouseDragged
mouseMoved
Soft Eng 3 - Damas - د. باسم قصٌبة 42
2009
Listeners of Components as
events sources of events
MouseListener
Component
mousePressed
mouseReleased
mouseEntered
mouseExited
mouseClicked
WindowListener
windowClosing
windowOpened
windowIconified
Window
windowDeiconified
windowClosed
windowActived
Soft Eng 3 - Damas - د. باسم قصٌبة 43
2009 windowDeactived
class ButtonsPanel extends JPanel implements
class ButtonsPanel extends JPanel implements ActionListener
ActionListener {
{ …………….
public void actionPerformed(ActionEvent e)
private JButton yellowButton, redButton, {
blueButton; Object source = e.getSource();
Color coleur = getBackground();
public ButtonsPanel()
{ if(source == yellowButton)
yellowButton = new JButton("Yellow"); coleur = Color.yellow;
else if (source == redButton)
redButton = new JButton("Red"); coleur = Color.red;
blueButton = new JButton("Blue"); else if(source == blueButton)
coleur = Color.blue;
add(yellowButton);
add(redButton); setBackground(coleur);
repaint();
add(blueButton); }
}
yellowButton.addActionListener(this);
redButton.addActionListener(this);
blueButton.addActionListener(this);
}
……
Soft Eng 3 - Damas - د. باسم قصٌبة 44
2009
Soft Eng 3 - Damas - د. باسم قصٌبة 45
2009
Visitor
Represent an operation to be performed on the elements of an object
structure.
Visitor lets you define a new operation without changing the classes of
the elements on which it operates.
ٌفصو تٍِ تٍْح ٍعطٍاخ ٍعٍْح ٗ اىَعاىداخ اىتً تعَو عيٍٖا
Composite Pattern ٌعَو ٍع اىـ
: ٍِ ىذٌْا ٕشٍٍتٍِ ٍتَاٌضت
ٗاحذج ىيَعطٍاخ
)Visitor( ٗاحذج ىيَعاىداخ
ٌسَح تإضافح ٍْإح عيى ٕشٍٍح اىَعطٍاخ تذُٗ تعذٌيٖا
OCP?