UML class diagram (Inheritance/Association)s<interfaces>InterfaceOneSolid line:extends+methodOne0Ainterfaceinterface>InterfaceTwoInterfaceThree+methodTwoo:doubie+methodThree(value:double)AZDashed line: implementsClassA+metodOne0+methodTwoO:double+methodThree(value:double)
UML class diagram (Inheritance/Association) Dashed line: implements Solid line: extends
Unit 2 Class Implementation equalsO/toStringOVector/ArrayListJDK5- Vector<String>- ArrayList<String>- For each loop (Iterable interface/iterator method)JUnit·Design Pattern
Unit 2 Class Implementation • equals()/toString() • Vector/ArrayList • JDK 5 − Vector<String> − ArrayList<String> − For each loop (Iterable interface/iterator method) • JUnit • Design Pattern
Vector and IteratorClientBankAccount-name:Stringbalance:double-accounts+getName:String+getBalanceO:double+addAccount(bankAccount:BankAccount)1.*+deposit(amount:double)+getAccountsiteratorO:Iterator+withdrawamount.double)+getNumberAccountsO:int
Vector and Iterator
methods defined in class VectorVector(.Constructsan empty collection.int size().Returns the number ofobjects in the collection.booleanisEmptyO. Determines if there are no objects in the collectionbooleancontains(Objectelem). Determines if the specified object is an elementofthecollection(asdeterminedbythemethodequals)boolean add(E o). Appends the specified object to the end of the collection.void add(int index, E element).Inserts the specified object at the specified indexposition, shifting any subsequentelements to the right (adds one to their indices)Eget(int index).Returnstheobjectatthe specified position.public E set(int index, E element).Replaces the element at the specified indexposition with the specified object.publicbooleanremove(Objecto).Removes thefirst occurrenceofthespecifiedobject (using method equals), shifting any subsequent elements to the left(subtractsonefromtheirindices)E remove(int index). Returnsthe object at the specified position after firstremoving it from the collection and shifting any subsequentelements to the left(subtractsonefromtheirindices)
methods defined in class Vector • Vector(). Constructs an empty collection. • int size(). Returns the number of objects in the collection. • boolean isEmpty(). Determines if there are no objects in the collection. • boolean contains(Object elem). Determines if the specified object is an element of the collection (as determined by the method equals). • boolean add(E o). Appends the specified object to the end of the collection. • void add(int index, E element). Inserts the specified object at the specified index position, shifting any subsequent elements to the right (adds one to their indices). • E get(int index). Returns the object at the specified position. • public E set(int index, E element). Replaces the element at the specified index position with the specified object. • public boolean remove(Object o). Removes the first occurrence of the specified object (using method equals), shifting any subsequent elements to the left (subtracts one from their indices). • E remove(int index). Returns the object at the specified position after first removing it from the collection and shifting any subsequent elements to the left (subtracts one from their indices)
Methods Defined in Class ArrayListArrayListO. Constructs an empty collectionint sizeO. Returns the number of objects in the collectionboolean isEmptyO. Determines if there are no objects in the collectionboolean contains(Objectelem). Determines ifthe specified object is anelement of the collection (as determined by the method equals).boolean add(E o). Appends the specified object to the end of the collectionvoid add(int index, E element). Inserts the specified object at the specifiedindex position, shifting any subsequent elements to the right (adds one totheir indices).E get(int index). Returns the object at the specified position.public E set(int index, E element). Replaces the element at the specifiedindex position with the specified object.public boolean remove(Object o). Removes the first occurrence of thespecified object (using method equals), shifting any subsequent elements tothe left (subtracts one from their indices).E remove(int index). Returns the object at the specified position after firstremoving it from the collection and shifting any subsequent elements to theleft (subtracts one from their indices)
Methods Defined in Class ArrayList • ArrayList(). Constructs an empty collection. • int size(). Returns the number of objects in the collection. • boolean isEmpty(). Determines if there are no objects in the collection. • boolean contains(Object elem). Determines if the specified object is an element of the collection (as determined by the method equals). • boolean add(E o). Appends the specified object to the end of the collection. • void add(int index, E element). Inserts the specified object at the specified index position, shifting any subsequent elements to the right (adds one to their indices). • E get(int index). Returns the object at the specified position. • public E set(int index, E element). Replaces the element at the specified index position with the specified object. • public boolean remove(Object o). Removes the first occurrence of the specified object (using method equals), shifting any subsequent elements to the left (subtracts one from their indices). • E remove(int index). Returns the object at the specified position after first removing it from the collection and shifting any subsequent elements to the left (subtracts one from their indices)