UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public.

Slides:



Advertisements
Similar presentations
Queues Printer queues Several jobs submitted to printer Jobs form a queue Jobs processed in same order as they were received.
Advertisements

Lab 8 Ordered list. OVERVIEW In an ordered list the elements are maintained in ascending (or descending) order based on the data contained in the list.
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Queue Overview Queue ADT Basic operations of queue
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Lecture 6 Feb 12 Goals: stacks Implementation of stack applications Postfix expression evaluation Convert infix to postfix.
List Implementations That Use Arrays Chapter 5. 2 Chapter Contents Using a Fixed-Size Array to Implement the ADT List An Analogy The Java Implementation.
Queues, Deques, and Priority Queues Chapter Chapter Contents Specifications for the ADT Queue Using a Queue to Simulate a Waiting Line The Classes.
CHAPTER 6 Stacks Array Implementation. 2 Stacks A stack is a linear collection whose elements are added and removed from one end The last element to be.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
© The McGraw-Hill Companies, 2006 Chapter 7 Implementing classes.
Crossword Puzzle Solver Michael Keefe. Solver structure.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 12 – Object-Oriented Design.
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
Arrays Construct array: new double[10] Store in variable of type double[] double[] data = new double[10];
Relationships between classes Using UML
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
Problem 1 Bank.  Manage customers’ bank account using the following operations: Create a new account given a customer’s name and initial account. Deposit.
A: A: double “4” A: “34” 4.
“The desire for safety stands against every great and noble enterprise.” – Tacitus Thought for the Day.
Chapter 4 ADTs Stack and Queue. 4-2 Formal ADT Specifications The Java interface construct lets us collect together method interfaces into a syntactic.
ITI 1120 Lab #10 Objects and Classes Slides by: Romelia Plesa, Sylvia Boyd, Alan Williams, Diana InkPen, Daniel Amyot, Gilbert Arbez, Mohamad Eid.
The Queue ADT.
Chapter 12 – Object-Oriented Design
Sections 3.4 Formal Specification
CSC111 Quick Revision.
Computing with C# and the .NET Framework
Chapter 18: Stacks and Queues.
while Repetition Structure
Efficiency of in Binary Trees
Lists The List ADT.
Stack and Queue APURBO DATTA.
Generic array list and casting C&K s7.7
CS Week 13 Jim Williams, PhD.
public class BankAccount{
CS 302 Week 10 Jim Williams.
Still Aggregation and Composition
Chapter 19: Stacks and Queues.
Review Operation Bingo
Lecture 2: Implementing ArrayIntList reading:
null, true, and false are also reserved.
Building Java Programs
Lesson Objectives Aims
Building Java Programs
UML & Programming Martin Fowler.
COMPUTER 2430 Object Oriented Programming and Data Structures I
searching Concept: Linear search Binary search
EE 422C Sets.
Queues: Implemented using Arrays
Lecture 2: Implementing ArrayIntList reading:
Introduction to Programming
UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public.
COMPUTER 2430 Object Oriented Programming and Data Structures I
The Vector Class An object of class Vector is similar to an array in that it stores multiple values However, a vector only stores objects does not have.
Barb Ericson Georgia Institute of Technology June 2005
Stacks CS-240 Dick Steflik.
ArrayLists 27-Apr-19.
Recursive Objects Singly Linked Lists.
Variables Here we go.
CSE 1030: Aggregation and Composition
Java: Variables, Input and Arrays
Barb Ericson Georgia Institute of Technology Oct 2005
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Chapter 9 The Priority Queue ADT
Objects with ArrayLists as Attributes
Chapter 11: Class Diagram
COMPUTER 2430 Object Oriented Programming and Data Structures I
Presentation transcript:

UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public Sales(String name1){ // } public void readProfits(){ public void displayProfits(){ public double highestProfit(){ public double totalProfit(){ public boolean deserveBonus(double amount){ Sales - name: string - monthlyProfit : double[] + Sales(in name1: string) + readProfits(): void + displayInfo(): void + highestProfit(): double + TotalProfit(): double + deserveBonus(in amount: double): boolean

يتألف من يضم

If you have trouble remembering the difference between composition and aggregation, just think of the alphabet.  Composition means destroy and the letters 'c' and 'd' are next to each other.

After adding one product + Purchase Order PRP 1 After adding one product Calling Environment Product p

After adding one product + After adding one product Product Group PDP 1 Product Copy Calling Environment Product p

UML Object Models: Aggregation, and Composition Example 3: +Car(in n : string, in d : string, in s : int, in y : int, in size : int) +display() +isFull() : bool +copyCar(in ca : Car) +addElement(in el : CarElements) : bool +PriceCar() : double +...........(in .........) -seatNb : int -year : int -ncel : int Car +CarElements(in c : string, in p : double) +CarElement(in E : CarElements) +.....(in .........) -code : string -price : double CarElements 1 * +KsuCars(in size : int) +isEmpty() : bool +searchCar(in ce : string) : int +getCar(in nm : string) : Car +AveragePrice(in y : int) : double +.........(in .......) +remove(in s : string) : bool -nbc : int KsuCars - name : string -id : string

Description of the different classes: Question: Implement all the classes with all their methods using the following descriptions. Description of the different classes:   Class CarElements: ü      The method display () displays the code and the price. ü      + …….. (in ……..) : if you need an other methods in this class you can add it. You can’t add another constructor. Class Car: ·        name id seatNb : Number of seats ·        year : Production year of car ·        ncel : number of CarElements object currently in an object of the class Car. ·        And other attribute(s) deduced from the UML diagram. ü      display (): Displays all the attributes of an object Car. ü      addElement (CarElements el): This method receives a CarElements object and adds it to the Car object. ü      priceCar(): Returns the sum of the CarElements price in an object of the class Car. + …….. (in ……..) : if you need an other methods in this class you can add it. Class KsuCars: ·        nbc : number of Car currently in an object of the class KsuCar. ·        And other attribute(s) deduced from the UML diagram. ü      display (): Displays all the attributes of an object KsuCars. ü      search (String ce): This method receives a String representing the name of a Car object and returns the array index of the car object. ü      getCar (String nm): This method receives a String representing the id of a Car object and returns the Car object if it’s exist. ü      removeCar (String s): Removes a Car according to its name. It will return a value true if the operation has been completed successfully, or false if not. ü      AveragePrice(int y): Calculates the average price of all car in an object of class KsuCars that produced after the year y. ü      + …….. (in ……..) : if you need an other methods in this class you can add it.

Case Study For each of the three UML class descriptions, write the corresponding java code. Write a class with a main method to test the three classes (Test the “add” methods)