So I'm trying to figure out why my get method doesn't pass its test. This is my attempt at the get method: public Value get(Object key) { //Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. for (Pair<Key,Value> item : list) { if (item.key.equals(key)) { return item.value; } } return null; } public Value put(Key key, Value value) { //Associates the specified value with the specified key in the map. for (Pair<Key,Value> item : list) { if (containsKey(key)==true) { //A map m is said to contain a mapping …

Member Avatar
Member Avatar
+0 forum 5

Hello I am trying to create a class that called Lootable and create subclasses such as trunk, locker, etc. that will contain items that can be looted, they will inherit their lootability from the Lootable class. I am thinking of using the ArrayList for this. I have thought of different ways to go about this and have written some code but I am having some difficulties. This is for and assignment and my app idea goes somewhat beyond the requirements of the lesson and no I do not expect someone to due this for me I would however like some …

Member Avatar
Member Avatar
+0 forum 7

Hello, I want to implement Change Listener in the Action Listener of a Button I have a color graph chooser and 2 buttons...Apply and Cancel to select the color of the color chooser i have implemented the Change Listener but I want the change listener to act on the Apply button click... Since the listener which I have written is not in the apply button it takes place even when I click on cancel button.... code for change listener final JColorChooser ColorChooser = new JColorChooser(Color.black); ColorChooser.getSelectionModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { newColor = ColorChooser.getColor(); } } ); code …

Member Avatar
Member Avatar
+0 forum 2

The End.