diff options
author | RossTheRoss <msattr@gmail.com> | 2019-12-08 11:02:59 -0600 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-12-08 11:02:59 -0600 |
commit | 16565d8cc3c72e2863b63ccb18e3e6aede0f3472 (patch) | |
tree | d908bb8fbbc4a010a0a3995fe7aa03f52e3aa337 /csci1913/Java | |
parent | Finish lab again (diff) | |
download | homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar.gz homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar.bz2 homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar.lz homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar.xz homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.tar.zst homework-16565d8cc3c72e2863b63ccb18e3e6aede0f3472.zip |
Start & Finish final Lab (13)
Diffstat (limited to '')
-rw-r--r-- | csci1913/Java/lab13_strap012.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/csci1913/Java/lab13_strap012.java b/csci1913/Java/lab13_strap012.java new file mode 100644 index 0000000..8f6746b --- /dev/null +++ b/csci1913/Java/lab13_strap012.java @@ -0,0 +1,31 @@ +class Test +{ + private static final String [] reserved = + { "and", + "begin", + "define", + "do", + "else", + "end", + "if", + "not", + "or", + "return", + "then", + "while" }; + + private static int hash(String name) + { + return (name.charAt(0) + name.charAt(name.length()-1)) * name.length() % 997; + } + + public static void main(String [] args) + { + for (int index = 0; index < reserved.length ; index += 1) + { + System.out.print("h(\"" + reserved[index] + "\") = "); + System.out.print(hash(reserved[index])); + System.out.println(); + } + } +}
\ No newline at end of file |