Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tumors;
- import java.util.Scanner;
- import java.io.IOException;
- import java.io.File;
- public class Tumors {
- private int[][] scanned;
- private int[][] detect;
- static Scanner scan = new Scanner(System.in);
- static boolean flag = true;
- public Tumors() throws IOException {
- scan = new Scanner(new File("Tumors.txt"));
- int scannedLength = scan.nextInt();
- int detectLength = scan.nextInt();
- scanned = new int[scannedLength][scannedLength];
- detect = new int[detectLength][detectLength];
- // sets up all numbers in the scanned array
- for (int i = 0; i < scanned.length; i++) {
- for (int j = 0; j < scanned[0].length; j++) {
- scanned[i][j] = scan.nextInt();
- }
- }
- for (int i = 0; i < detect.length; i++) {
- for (int j = 0; j < detect[0].length; j++) {
- detect[i][j] = scan.nextInt();
- }
- }
- }
- public void printScan() {
- System.out.println("The scan is as follows: ");
- for (int i = 0; i < scanned.length; i++) {
- for (int j = 0; j < scanned[0].length; j++) {
- if (scanned[i][j] == 1) {
- System.out.print("+");
- } else {
- System.out.print("_");
- }
- }
- System.out.println();
- }
- }
- public void printTumorPossibility() {
- System.out.println("\nThe tumor possibility is as follows: ");
- for (int i = 0; i < detect.length; i++) {
- for (int j = 0; j < detect[0].length; j++) {
- if (detect[i][j] == 1) {
- System.out.print("+");
- } else {
- System.out.print("_");
- }
- }
- System.out.println();
- }
- }
- public void checkTumorPossibilities() {
- int[][] segmentOfScan = new int[detect.length][detect[0].length];
- boolean isTumor = false;
- for (int scoot = 0; scoot < scanned.length; scoot++) {
- for (int i = 0; i < detect.length; i++) {
- for (int j = 0; j < detect.length; j++) {
- segmentOfScan[i][j] = scanned[i + scoot][j + scoot];
- }
- isTumor = check(segmentOfScan);
- if(isTumor){
- System.out.println("THERE IS A TUMOR!!!!!");
- }
- }
- }
- }
- public boolean check(int[][] arr){
- for(int i = 0; i<arr.length; i++){
- for(int j = 0; j < arr[0].length; j++){
- if(arr[i][j] != detect[i][j]){
- return false;
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement