Initial Commit
This commit is contained in:
40
Source Code/Midterm/CarComparable.java
Normal file
40
Source Code/Midterm/CarComparable.java
Normal file
@ -0,0 +1,40 @@
|
||||
public class Car implements Comparable<Car>{
|
||||
|
||||
private String brand;
|
||||
private int year;
|
||||
|
||||
public Car(String brandIn, int yearIn){
|
||||
brand = brandIn;
|
||||
year = yearIn;
|
||||
}
|
||||
|
||||
public int compareTo(Car otherCar) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (brand.compareTo(obj2) > 0) {
|
||||
return 1;
|
||||
}
|
||||
else if (obj1.compareTo(obj2) < 0) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
int obj1Int = Integer.parseInt(String.valueOf(code.charAt(1) + code.charAt(2) + code.charAt(3)));
|
||||
int obj2Int = Integer.parseInt(String.valueOf(other.getCode().charAt(1) + other.getCode().charAt(2) + other.getCode().charAt(3)));
|
||||
if (obj1Int < obj2Int) {
|
||||
return 1;
|
||||
}
|
||||
else if (obj1Int > obj2Int) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
Source Code/Midterm/Puzzle.java
Normal file
42
Source Code/Midterm/Puzzle.java
Normal file
@ -0,0 +1,42 @@
|
||||
public class Puzzle {
|
||||
|
||||
public static boolean threeSearch(int[][] map) {
|
||||
|
||||
for (int row = 0; row < map.length; row++) {
|
||||
for (int col = 0; col < map[row].length; col++ {
|
||||
if (map[row][col] == 7) {
|
||||
|
||||
if (row == 0 & col == 0) {
|
||||
if (map[row+1][col] == 3 | map[row][col+1] == 3)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
else if ((row == map.length & col == map[row].length) {
|
||||
if (map[row-1][col] == 3 | map[row][col-1] == 3)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
else if ((row == map.length & col == 0) {
|
||||
if (map[row-1][col] == 3 | map[row][col+1] == 3)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
else if ((row == 0 & col == map[row].length) {
|
||||
if (map[row+1][col] == 3 | map[row][col-1] == 3)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
else if (row == 0| col == 0) {
|
||||
//condition for if on top left edges (needst to be split up into two conditionals no time)
|
||||
}
|
||||
else if (row == map.length | col == map[row].length) {
|
||||
//condition for if on bottom right edges (needst to be split up into two conditionals no time)
|
||||
}
|
||||
else (map[row+1][col] == 3 | map[row][col+1] == 3 | map[row-1][col] == 3 | map[row][col-1] == 3) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user