Merge branch 'Compile-Code' of https://github.com/Patel-Mann/CPSC-499 into Compile-Code
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
public class Test {
|
public class Test_0 {
|
||||||
public int methodForLoop() {
|
public int methodForLoop() {
|
||||||
int val = 1;
|
int val = 1;
|
||||||
|
|
||||||
28
Assignment-3/javaparser-1.0.0/Test_1.java
Normal file
28
Assignment-3/javaparser-1.0.0/Test_1.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
public class test_1{
|
||||||
|
public int calculate(int x){
|
||||||
|
switch(x){
|
||||||
|
case 1: x += 10;
|
||||||
|
break;
|
||||||
|
case 2: x *= 2:
|
||||||
|
break;
|
||||||
|
default: x = -1;
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
x = riskyOp(x);
|
||||||
|
} catch (Exception e){
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
return finalValue(x);
|
||||||
|
}
|
||||||
|
private int riskyOp(int input) Exception {
|
||||||
|
if (input < 0){
|
||||||
|
throw new Exception("Negative input");
|
||||||
|
}
|
||||||
|
return input + 5;
|
||||||
|
}
|
||||||
|
private int finalValue(int val){
|
||||||
|
return val*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = this.calculate(2);
|
||||||
|
}
|
||||||
12
Assignment-3/javaparser-1.0.0/Test_2.java
Normal file
12
Assignment-3/javaparser-1.0.0/Test_2.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
public class Test_2{
|
||||||
|
public int factorial(int n){
|
||||||
|
if(n < 0){
|
||||||
|
reutrn -1;
|
||||||
|
}
|
||||||
|
if (n == 0|| n==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return n * factorial(n-1);
|
||||||
|
}
|
||||||
|
int result = this.factorial(5);
|
||||||
|
}
|
||||||
17
Assignment-3/javaparser-1.0.0/Test_3.java
Normal file
17
Assignment-3/javaparser-1.0.0/Test_3.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
public class Test_3{
|
||||||
|
public int search(int [][] matrix, int to_search){
|
||||||
|
for(int i = 0; i < matrix.lenght; i++){
|
||||||
|
for(int j = 0; j < matrix[i].legth; j++) {
|
||||||
|
if (matrix[i][j] == to_search){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
boolean result = this.contains(new int[][] {
|
||||||
|
{1,2,3},
|
||||||
|
{22,42,45},
|
||||||
|
{38,26,16}}, 42);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user