public class Player extends Creature{ private Hashtable hT = new Hashtable();. /* â¦. Content of the class ⦠*/ public void writeData(int key, Object data){ ...
CMPT 225 : Lab 5, Correction Heaps, sorting and hash tables I. Complete the Player (1 pt) In creature.player, you had two functions to complete. We want to write and retrieve data, and you had to back it up using a hash table. Thus, the result is: public class Player extends Creature{ private Hashtable hT = new Hashtable(); /* …. Content of the class … */ public void writeData(int key, Object data){ hT.put(key, data); } public Object readData(int key){ return hT.get(key); } } You also had to make sure that Philippe was using the writeData method, so you had to add a line in the talk method of creature.people.Philippe saying p.writeData(1, “whatever”). II. Complete creature.people.Awin (3 pts) public AbstractMap reward(Stack s){ HashMap hm = new HashMap(); // when you look in the Javadoc, you see which classes extend AbstractMap int money = s.size()*50; // we know that each customer pays 50$ so the amount of money is size*50 money *= 0.5; // we want to save half of the money so we already take it out while(!s.empty()){ // and then for each customer, from the last one to the first one money *= 0.5; // we give him half of the remaining. We have n/4 + n/8 + n/16 … → n/2 hm.put(s.pop(), ""+money); // to convert the money into a String just add "" before } // this should return the benefit after having rewarded the customers return hm; } III.
Complete creature.people.Helia (2 pts)
// a comparator is a class that implements Comparator of a certain object. By subtracting the two heights we know which // goblin is taller. You can also explicitly say “if ( o1.getHeight() > o2.getHeight() ) return …” and you get partial marks then. private class GoblinCmp implements Comparator{ public int compare(Goblin o1, Goblin o2) { return o1.getHeight() - o2.getHeight(); } }
// as we saw in class to sort students, if we want to use a comparator we need to get an instance of it private Comparator getComparator(){ return new GoblinCmp(); }
private Goblin[] goblinSort(Goblin[] array, Comparator cmp){ int i = 1, j = 2 ; // we said by e-mail that you had to use Gnome sort, and you can just get it from Wikipedia while (i < array.length){ if( cmp.compare(array[i-1], array[i])
You will add functionalities to the Turtle created in class. You will ... The way you communicate to the window is by sending it objects through addDrawing. Since.
... we will record when you play. Come in the lab (July 16 th. ) so that we can do the recording; you can also arrange for Wednesday (July 15 th. ) early afternoon.
I. Reading 1. 1) A query is a graph (i.e. a set of nodes and edges) with additional specifications, such as the type of nodes and/or edges and quantities. Several ...
Add two symbols to the language of the turtle: [ that pushes a state and ] that pops it. In ... If only three people go that far, you'll win the points without having to ...
Adds an integer (its position depends on its value). 0.5 pt. Function name: remove. Removes the integer with the i-th value from lowest to highest. Example: we ...
in numerous situations that go well beyond storing a key and an element. ... The language at the end of this section is like a conversation: you say different things ...
II. Reading 1: A visual language for querying and updating graphs. 1) For a given query, can you have several matches? Explain why using the word subgraphs.
hometown, his favourite activities, etc. Thus, we will extend each node with a dictionary, represented as a hash table, and use this information to query the graph.
other data structures seen in the course. Example: L1 = {0, 7, 3, 2, 9} L2 = {1, 2, 3, 4}. Show: 2, 3 b) Express the space and time complexity of your method. c) ...
independent (but for 3d) and are proposed in increasing order of difficulty. The instructor and ... c) Define a simple algorithm on a Binary Search Tree. Show a few instances of ... perform benchmarking on our data structures. a) To perform a ...
In lecture Designing good algorithms, you saw a trick to swap the content of two ... A supermarket uses an Array as a data structure to store its produces.
All of the following functions must be written at the end of the Tree class. You do not have any reason to ... then google ternary operator⦠} protected boolean ...
hash tables, discuss their advantages and disadvantages, and implement it in Java. ... The approach taken in this course relies on three aspects: participation, ... practice and example, it was decided to have short questions in a lecture that the ..
After installation, test the light system to ensure that it is operating properly. ⢠After testing is ... The Motor-Gear Reducer Assembly is a sealed unit. Therefore, no ...
If we want to see how we declared the tables and the views, refers to the ... like to use it, by example to Update an Employee, instead of doing it on each table.
SYSTEMES DE SECURITE DE TAILLE MOYENNE GERANT JUSQU'A 30,000 UTILISATEURS ET 4092 PORTES. PILOTE PAR LE ... PROX, CARTE A PUCE ET BIOMETRIQUES DE ROSSLARE AVEC LA SELECTION DE CARTES D'IDENTITE RFID ... Permet la gestion des données des utilisateurs,
2011, when Steve Jobs (the founder of the company) resigned, because of his medical condition. But he is extremely well paid. He got a total remuneration of 74 ...