public class Item
{
/** Name is the first part of the item. Ex. Long Bow */
/**
* Defines what an item object is.
* @param name of item.
*/
{
this .name = name;
this .type = type;
}
public int getItemSize( )
{
switch ( type)
{
case "Ring" : return 1 ;
case "Amulet" : return 1 ;
case "Helm" : return 4 ;
case "Body Armor" : return 6 ;
case "Boots" : return 4 ;
case "Belt" : return 2 ;
case "Gloves" : return 4 ;
default : Other.myHashTable .get ( name) ;
}
}
{
return name;
}
}
public class other
{
public static HashTable
< String , Integer
> myHashTable
= new HashTable
<> ( ) ;
public static void main
( String [ ] args
) {
// Add all the data into the HashTable.
Item bigSword = new Item( "Big Sword" , "Weapon" ) ;
System .
out .
println ( "The size of this weapon is: " + bigSword.
getItemSize ( ) ) ; }
}
cHVibGljIGNsYXNzIEl0ZW0KewogICAgLyoqIE5hbWUgaXMgdGhlIGZpcnN0IHBhcnQgb2YgdGhlIGl0ZW0uIEV4LiBMb25nIEJvdyAqLwogICAgcHJpdmF0ZSBTdHJpbmcgbmFtZTsKCXByaXZhdGUgU3RyaW5nIHR5cGU7CgkKICAgIC8qKgogICAgICogRGVmaW5lcyB3aGF0IGFuIGl0ZW0gb2JqZWN0IGlzLgogICAgICogQHBhcmFtIG5hbWUgb2YgaXRlbS4KICAgICAqLwogICAgcHVibGljIEl0ZW0oU3RyaW5nIG5hbWUsIFN0cmluZyB0eXBlKQogICAgewogICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CgkJdGhpcy50eXBlID0gdHlwZTsKICAgIH0KCiAgICBwdWJsaWMgaW50IGdldEl0ZW1TaXplKCkKICAgIHsKICAgICAgICBzd2l0Y2godHlwZSkKICAgICAgICB7CiAgICAgICAgCWNhc2UgIlJpbmciOiByZXR1cm4gMTsKICAgICAgICAJY2FzZSAiQW11bGV0IjogcmV0dXJuIDE7CiAgICAgICAgCWNhc2UgIkhlbG0iOiByZXR1cm4gNDsKICAgICAgICAJY2FzZSAiQm9keSBBcm1vciI6IHJldHVybiA2OwogICAgICAgIAljYXNlICJCb290cyI6IHJldHVybiA0OwogICAgICAgIAljYXNlICJCZWx0IjogcmV0dXJuIDI7CiAgICAgICAgCWNhc2UgIkdsb3ZlcyI6IHJldHVybiA0OwogICAgICAgIAlkZWZhdWx0OiBPdGhlci5teUhhc2hUYWJsZS5nZXQobmFtZSk7CiAgICAgICAgfQogICAgfQoKICAgIHB1YmxpYyBTdHJpbmcgZ2V0TmFtZSgpCiAgICB7CiAgICAgICAgcmV0dXJuIG5hbWU7CiAgICB9Cn0KCnB1YmxpYyBjbGFzcyBvdGhlcgp7CglwdWJsaWMgc3RhdGljIEhhc2hUYWJsZTxTdHJpbmcsIEludGVnZXI+IG15SGFzaFRhYmxlID0gbmV3IEhhc2hUYWJsZTw+KCk7CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpCgl7CgkJLy8gQWRkIGFsbCB0aGUgZGF0YSBpbnRvIHRoZSBIYXNoVGFibGUuCgkJCgkJSXRlbSBiaWdTd29yZCA9IG5ldyBJdGVtKCJCaWcgU3dvcmQiLCAiV2VhcG9uIik7CgkJCgkJU3lzdGVtLm91dC5wcmludGxuKCJUaGUgc2l6ZSBvZiB0aGlzIHdlYXBvbiBpczogIiArIGJpZ1N3b3JkLmdldEl0ZW1TaXplKCkpOwoJfQp9
compilation info
Main.java:1: error: class Item is public, should be declared in a file named Item.java
public class Item
^
Main.java:38: error: class other is public, should be declared in a file named other.java
public class other
^
Main.java:40: error: cannot find symbol
public static HashTable<String, Integer> myHashTable = new HashTable<>();
^
symbol: class HashTable
location: class other
Main.java:28: error: package Other does not exist
default: Other.myHashTable.get(name);
^
Main.java:40: error: cannot find symbol
public static HashTable<String, Integer> myHashTable = new HashTable<>();
^
symbol: class HashTable
location: class other
5 errors
stdout