aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci1913/Java/lab13_strap012.java
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2020-02-09 08:46:52 -0600
committerRossTheRoss <msattr@gmail.com>2020-02-09 08:46:52 -0600
commitbd1d350c376b45e334697851e29b2f79fee0c956 (patch)
treeeb242032a64442caef7a35434400eb0818911e9a /OLD/csci1913/Java/lab13_strap012.java
parentDo micro prelab (diff)
parentRename file (diff)
downloadhomework-bd1d350c376b45e334697851e29b2f79fee0c956.tar
homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.gz
homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.bz2
homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.lz
homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.xz
homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.zst
homework-bd1d350c376b45e334697851e29b2f79fee0c956.zip
Merge branch 'master' of github.com:RosstheRoss/TestingFun
Diffstat (limited to 'OLD/csci1913/Java/lab13_strap012.java')
-rw-r--r--OLD/csci1913/Java/lab13_strap012.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/OLD/csci1913/Java/lab13_strap012.java b/OLD/csci1913/Java/lab13_strap012.java
new file mode 100644
index 0000000..8645a98
--- /dev/null
+++ b/OLD/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()) % 255;
+ }
+
+ 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