statement that is presented by the class given in part 1. 4. Write a pseudo code to reflect the problem statement of step 3 and the class code of step 1.
1 2 An interface that describes the operations of a bag of objects. 3 @author Frank M. Carrano, Timothy M. Henry 4 *1 5 public interface BagInterface<T> 6 { 7 /** Gets the current number of entries in this bag. 8 @return The integer number of entries currently in the bag. */ 9 public int getCurrentSize(); 10 11 /** Sees whether this bag is empty. 12 @return True if the bag is empty, or false if not. */ 13 public boolean isEmpty(); 14 15 /** Adds a new entry to this bag. 16 @param newEntry The object to be added as a new entry. 17 @return True if the addition is successful, or false if not. */ 18 public boolean add (T newEntry); 19 20 /** Removes one unspecified entry from this bag, if possible. 21 @return Either the removed entry, if the removal. 22 was successful, or null. */ 23 public T remove (); 24
24 25 /** Removes one occurrence of a given entry from this bag, if possible. 26 @param anEntry The entry to be removed. 27 @return True if the removal was successful, or false if not. 28 public boolean remove (T anEntry); 29 30 /** Removes all entries from this bag. */ 31 public void clear(); 32 33 /** Counts the number of times a given entry appears in this bag. 34 @param anEntry The entry to be counted. 35 @return The number of times anEntry appears in the bag. 36 public int getFrequency of (T anEntry); 37 38 /** Tests whether this bag contains a given entry. 39 @param anEntry The entry to find. 40 @return True if the bag contains anEntry, or false if not. */ 41 public boolean contains (T anEntry); 42 43 /** Retrieves all entries that are in this bag. 44 @return A newly allocated array of all the entries in the bag. 45 Note: If the bag is empty, the returned array is empty. *) public T[] toArray(); 46 47 } // end BagInterface
1. Write a CRC card and a class diagram for a proposed class called......... (see attached source code for each Lab). 2. Run the program and take screen shot of your result. 3. Write a short problem 1. Write a CRC card and a class diagram for a proposed class called......... (see attached source code for each Lab). 2.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am