diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-24 18:43:52 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-24 18:43:52 -0600 |
commit | 0bbc4cb511bd90cebf94ccfcfce5ff8983ebb918 (patch) | |
tree | 3ead995c78dbc0112a37e03056b440dbebd571e8 | |
parent | b9c7f34926bfec0b7704b09865b74cb42c66ab6d (diff) |
Boil new array tests
-rw-r--r-- | boil/tests/ex45.java | 19 | ||||
-rw-r--r-- | boil/tests/ex46.java | 32 | ||||
-rw-r--r-- | boil/tests/ex47.java | 24 | ||||
-rw-r--r-- | boil/tests/ex48.java | 23 |
4 files changed, 98 insertions, 0 deletions
diff --git a/boil/tests/ex45.java b/boil/tests/ex45.java new file mode 100644 index 0000000..72f85d4 --- /dev/null +++ b/boil/tests/ex45.java @@ -0,0 +1,19 @@ +class ex45 { + public static void main(String[] z) { + int result ; + A a ; + a = new A() ; + result = a.run() ; + System.out.println(result) ; + } +} + +class A { + + int[] arr ; + + public int run() { + arr = new int[10] ; + return arr.length ; + } +} diff --git a/boil/tests/ex46.java b/boil/tests/ex46.java new file mode 100644 index 0000000..55724d6 --- /dev/null +++ b/boil/tests/ex46.java @@ -0,0 +1,32 @@ +class ex46 { + public static void main(String[] z) { + int result ; + A a ; + a = new A() ; + System.out.println(a.foo()) ; + System.out.println(a.foo()) ; + result = a.bar(10, 20); + System.out.println(result) ; + } +} + +class A { + + int c ; + int d ; + + public int foo() { + d = 0 ; + c = 1 + 2 ; + d = c + d ; + return d ; + } + + public int bar(int a, int b) { + int result ; + c = a ; + d = b ; + result = c * d ; + return result ; + } +} diff --git a/boil/tests/ex47.java b/boil/tests/ex47.java new file mode 100644 index 0000000..b8d4b3a --- /dev/null +++ b/boil/tests/ex47.java @@ -0,0 +1,24 @@ +class ex47 { + public static void main(String[] z) { + int result ; + A a ; + a = new A() ; + System.out.println(a.set(42)) ; + System.out.println(a.get()) ; + } +} + +class A { + + int[] x ; + + public int set(int b) { + x = new int[12] ; + x[5] = b ; + return x.length ; + } + + public int get() { + return x.length ; + } +} diff --git a/boil/tests/ex48.java b/boil/tests/ex48.java new file mode 100644 index 0000000..21424ba --- /dev/null +++ b/boil/tests/ex48.java @@ -0,0 +1,23 @@ +class ex48 { + public static void main(String[] z) { + int result ; + A a ; + a = new A() ; + System.out.println(a.set(42)) ; + System.out.println(a.get()) ; + } +} + +class A { + + int x ; + + public int set(int b) { + x = b ; + return x ; + } + + public int get() { + return x ; + } +} |