一万块钱投资,求助!!!关系到我朋友一万块学费。。

求助!!!关系到我朋友一万块学费。。 - 故障解答 - 电脑教程网

求助!!!关系到我朋友一万块学费。。

日期:2006-04-04   荐:
求助!!!关系到我朋友一万块学费。。package nz.ac.massey.iist.p159201.assignment1;/** * Tests for SimpleDictionary. * @author Jens Dietrich * @version 1.0 * @see SimpleDictionary */public class SimpleDictionaryTests extends DictionaryTests{ /** * Default constructor for test class SimpleDictionaryTestCases */ public SimpleDictionaryTests() { super(); } /** * Sets up the test fixture. * * Called before every test case method. */ protected void setUp() { this.dictionary = new SimpleDictionary(); }}package nz.ac.massey.iist.p159201.assignment1;/** * Sample implementation of the Dictionary interface using a standard java container class. * @author Jens Dietrich * @version 1.0 */public class SimpleDictionary implements Dictionary { private java.util.Map delegate = new java.util.Hashtable(); /** * Set a new key-value association. * @param key a key * @param value a value */ public void put(Object key,Object value) { this.delegate.put(key,value); } /** * Get the value for a certain key. * @param key a key * @return the value associated with this key or null indicating that there is no value for this key */ public Object get(Object key) { return this.delegate.get(key); } /** * Get the number of associations. * @return an integer */ public int getSize() { return this.delegate.size(); } /** * Remove the association with the given key. * Return true if this suceeds, false otherwise (i.e., if there was no association with this key). * @param key a key * @return a boolean */public boolean remove(Object key) { return this.delegate.remove(key)!=null; }}package nz.ac.massey.iist.p159201.assignment1;/** * Reusable test cases for Dictionary. * @author Jens Dietrich * @version 1.0 */public class DictionaryTests extends junit.framework.TestCase{ protected Dictionary dictionary = null; /** * Default constructor for test class DictionaryTestCases */ public DictionaryTests() { } /** * Sets up the test fixture. * * Called before every test case method. */ protected void setUp() { } /** * Tears down the test fixture. * * Called after every test case method. */ protected void tearDown() { } // test 1 public void test1() { Object key = "key"; Object value = "value"; this.dictionary.put(key,value); Object value2 = dictionary.get(key); assertTrue(value==value2); } // test 2 - like test 1 , but used objects (not strings) public void test2() { Object key = new Object(); Object value = new Object(); this.dictionary.put(key,value); Object value2 = dictionary.get(key); assertTrue(value==value2); } // test 3 - tests size public void test3() { this.dictionary.put("key1","value1"); assertTrue(this.dictionary.getSize()==1); } // test 4 - tests size public void test4() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); assertTrue(this.dictionary.getSize()==2); } // test 5 - tests size public void test5() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); this.dictionary.put("key3","value3"); assertTrue(this.dictionary.getSize()==3); } // test 6 - tests size and remove public void test6() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); this.dictionary.put("key3","value3"); // remove one at the start boolean removalOK = this.dictionary.remove("key1"); assertTrue(removalOK && this.dictionary.getSize()==2); } // test 7 - tests size and remove public void test7() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); this.dictionary.put("key3","value3"); // remove one in the middle boolean removalOK = this.dictionary.remove("key2"); assertTrue(removalOK && this.dictionary.getSize()==2); } // test 8 - tests size and remove public void test8() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); this.dictionary.put("key3","value3"); // remove one at the end boolean removalOK = this.dictionary.remove("key3"); assertTrue(removalOK && this.dictionary.getSize()==2); } // test 9 - tests size and remove public void test9() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value2"); this.dictionary.put("key3","value3"); // try to remove one that does not exist boolean removalOK = this.dictionary.remove("key4"); assertTrue(!removalOK && this.dictionary.getSize()==3); } // test 10 - adding the same value twice with two different keys is ok public void test10() { this.dictionary.put("key1","value1"); this.dictionary.put("key2","value1"); assertTrue(this.dictionary.getSize()==2); } // test 11 - stress test - try whether it works with 1000 associations public void test11() { Object[] keys = new Object[1000]; Object[] values = new Object[1000]; for (int i=0;i<keys.length;i ) { keys[i] = "key" i; values[i] = "value" i; this.dictionary.put(keys[i],values[i]); } assertTrue(this.dictionary.get(keys[0]).equals(values[0]) && this.dictionary.get(keys[999]).equals(values[999])); }}package nz.ac.massey.iist.p159201.assignment1;/** * Interface describing a data structure to store key-value associations. * @author Jens Dietrich * @version 1.0 */public interface Dictionary{/** * Set a new key-value association. * @param key a key * @param value a value */void put(Object key,Object value);/** * Get the value for a certain key. * @param key a key * @return the value associated with this key or null indicating that there is no value for this key */Object get(Object key);/** * Get the number of associations. * @return an integer */int getSize();/** * Remove the association with the given key. * Return true if this suceeds, false otherwise (i.e., if there was no association with this key). * @param key a key * @return a boolean */boolean remove(Object key);}这是4个JAVA文件。。需要完成。。谁能帮帮我朋友?gt;>!<卑?br>分不够可以再加的?gt;>!?br>实现的功能是输入一个KEY,输出一个VALUE,类似中英文翻译。。自已写?gt;>9δ芏剂谐隼戳恕!!0ァ!?hr>唉,小弟对JAVA是不知所以?gt;>?br>诸位能帮我把上面的填一下么?唉,我也没办法啊nimifeng(蜜蜂不小了.) 能不能帮帮我啊分不够再加。。功能大概是这样的:支持多次输入并保存KEY,VALUE,支持输入KEY获取VALUE,支持获得当前(KEY,VALUE)的位置,就是处于第几个,还有支持删除。。谢谢大家了。。没有设计书,又没有数据结构,说的还不详细,谁没事干这活呀。。。大家都挺忙的..咳....这种事这里还是蛮多的..老是..
标签: