I want to know how to translate the design into a computer program write an interface class java and please put on the comments
I would use the eclipse
This lab is a stepping stone to project 01. The ADT Bag is a group of items, much like what you might have with a bag of groceries. The ADT Bag should have the following operations. You should use the same operation names that are shown below.
• create an empty bag that can hold up to 50 items, • put an item at the end of the list of the bag (insert(item)), • remove the last item in the bag (removeLast()), • remove a random item from the bag (removeRandom()), (Note: a random item is an item at a random index.) • get the index of the first occurrence of an item from the bag if it is existed (get(item)), • get a reference to an item at position index( get(index)), • check how many items are in the bag (size()), • check to see if the bag is full (isFull()), • check to see if the bag is empty( isEmpty()), • and completely empty the bag (makeEmpty()).
To design the ADT Bag, create a UML class diagram and include the designs of the above-mentioned operations except the constructor (the first one). By standard, constructors shouldn’t be included in an UML class diagram. Constructors should be included in the classes that implement the design. To translate the design into a computer program, write an interface class(java) or an abstract class(C++). In the interface(Java), you should only include the method headers. In the abstract class(C++), all functions should be pure virtual functions. Save the class diagram and its translation into a folder. Zip the folder, and submit the zipped file on time in Blackboard. One submission per lab.
Ans:
In the UML diagram show below note that the methods insert(), removeLast(),removeRandom() would return a bool(0 denoting success,1 denoting error) since the method might be invalid in the event of the ADT Bag being either full or competely empty,since it's not posssible to add more elements to a completely filled ADT Bag or remove elements from an emptyone.
| ADT BAG |
|
+ insert(itm : item):bool) +removeLast:bool +removeRandom():bool +get(itm:item):int +get(id:index):int* +size():int +isFull():bool +isEmpty():bool +makeEmpty():bool |
:And also
Note the C++ translation of th eaforementioned UML diagram into functions.
======================
// An abstract class
class ADT Bag{
//Data members
public:
//pure virtual Functions
virtual bool insert(Item item)=0;
virtual bool removeLast()=0;
virtual bool removeRandom()=0;
virtual int get (Item item)=0;
virtual int* get(int index)=0;
virtual int size()=0;
virtual bool isFull()=0;
virtual bool isEmpty()=0;
virtual void makeEmpty()=0;
};
I want to know how to translate the design into a computer program write an interface...
I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem. The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...
The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should be included in an interface.) Specify operations to create an empty bag that can hold up to 100...
Part A is done, I do not know how to start these steps..
"In computer science, an abstract data type (ADT) is a mathematical model for data types where a data type is defined by its behavior (semantics) from the point of view of a user of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations." (Source: "Abstract Data Types." Wikipedia. Wikimedia Foundation, 2 Nov. 2016. Web. 9...
Given the Interface Code write a java class that implements this interface and show the working functionality in the main method: public interface CustomList<T> { /** * This method should add a new item into the <code>CustomList</code> and should * return <code>true</code> if it was successfully able to insert an item. * @param item the item to be added to the <code>CustomList</code> * @return <code>true</code> if item was successfully added, <code>false</code> if the item was not successfully added (note: it...
Complete an Array-Based implementation of the ADT List including a main method and show that the ADT List works. Draw a class diagram of the ADT List __________________________________________ public interface IntegerListInterface{ public boolean isEmpty(); //Determines whether a list is empty. //Precondition: None. //Postcondition: Returns true if the list is empty, //otherwise returns false. //Throws: None. public int size(); // Determines the length of a list. // Precondition: None. // Postcondition: Returns the number of items in this IntegerList. //Throws: None....
Part I: Create a doubly linked circular list class named LinkedItemList that implements the following interface: /** * An ordered list of items. */ public interface ItemList<E> { /** * Append an item to the end of the list * * @param item – item to be appended */ public void append(E item); /** * Insert an item at a specified index position * * @param item – item to be...
USE JAVA: Given the Interface Code and the Interface Implementation Code; Write Junit Tests to test all fuctionality. ------------- Interface code: public interface CustomList { /** * This method should add a new item into the CustomList and should * return true if it was successfully able to insert an item. * @param item the item to be added to the CustomList * @return true if item was successfully added, false if the item was not successfully added (note: it...
JAVA - Circular Doubly Linked
List
Does anybody could help me with this method below(previous)?
public E previous() {
// Returns the previous Element
return null;
}
Explanation:
We have this class with these two implemented
inferfaces:
The interfaces are:
package edu.ics211.h04;
/**
* Interface for a List211.
*
* @author Cam Moore
* @param the generic type of the Lists.
*/
public interface IList211 {
/**
* Gets the item at the given index.
* @param index the index....
I need help with the Implementation of an Ordered List (Template Files) public interface OrderedStructure { public abstract int size(); public abstract boolean add( Comparable obj ) throws IllegalArgumentException; public abstract Object get( int pos ) throws IndexOutOfBoundsException; public abstract void remove( int pos ) throws IndexOutOfBoundsException; public abstract void merge( OrderedList other ); } import java.util.NoSuchElementException; public class OrderedList implements OrderedStructure { // Implementation of the doubly linked nodes (nested-class) private static class Node { private Comparable value; private...
10.3 Example. When you first declare a new list, it is empty and its length is zero. If you add three objects—a, b, and c—one at a time and in the order given, to the end of the list, the list will appear as a b c The object a is first, at position 1, b is at position 2, and c is last at position 3.1 To save space here, we will sometimes write a list’s contents on one...