Sign In
Not register? Register Now!
Pages:
1 page/≈275 words
Sources:
Check Instructions
Style:
Other
Subject:
IT & Computer Science
Type:
Other (Not Listed)
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 5.4
Topic:

Computer Science Project: Java Programming

Other (Not Listed) Instructions:

PLEASE GIVE YOUR BID TO SUPPORT! CODING TASK
A simple computer science project in Java

Other (Not Listed) Sample Content Preview:
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author
*/
public class Skyscraper {
/**
* @param args the command line arguments
*/
//Declare class variables
private int Dim;
private int value;
private int[][] myBoard;
public void loadPuzzle() {
//Create an object of the scanner class. This helps in reading in values
Scanner scn = new Scanner(System.in);
System.out.printf("Enter board dimension : ");
// read the board dimension
Dim = scn.nextInt();
// create a board as a 2 dimensional square integer array
myBoard = new int[Dim][Dim];
int m=0;
// Loop through the length of the array and read the values from input
while(m
System.out.println("Enter numbers for row " + (int)(m+1) + " separated by a single space.");
for (int n = 0; n < Dim; ++n) {
value = scn.nextInt();
// Check validity of height entered. If correct add it ti the 2 dimensional array
if(value>0 && value<=Dim){
myBoard[m][n] = value;
}
else {
System.out.println(value + " is not a valid height. It should be an integer between 1 and "+Dim+"");
// decrement by 1 and skip
n=n-1;
continue;
}
}
m++;
}
}
private int[][] getBoard() {
return myBoard;
}
public void print(int[][] myBoard) {
for (int[] boardRow : myBoard) {
for (int q = 0; q < Dim; ++q) {
System.out.printf(boardRow[q] + " ");
}
System.out.printf("\n");
}
}
public void printWithVisibility(int[][] board,ArrayList list) {
System.out.println("\nPRINTING BOARD WITH VISIBILITY");
// Print upper line scores for columns
System.out.print(" ");
for (Object list11 : (ArrayList) list.get(0)) {
System.out.print(list11+" ");
}
System.out.println(" ");
int w=0;
for (int[] boardRow : myBoard) {
for (int q = 0; q < Dim; ++q) {
if(q==0){
ArrayList list_ = (ArrayList) list.get(1);
System.out.print(list_.get(w)+"|");
}
System.out.printf(boardRow[q] + " ");
}
ArrayList list_ = (ArrayList) list.get(3);
System.out.print("|"+list_.get(w));
System.out.printf("\n");
w++;
}
// print bottom visibility for rows
System.out.print(" ");
for (Object list11 : (ArrayList) lis...
Updated on
Get the Whole Paper!
Not exactly what you need?
Do you need a custom essay? Order right now:

You Might Also Like Other Topics Related to scientific essays:

HIRE A WRITER FROM $11.95 / PAGE
ORDER WITH 15% DISCOUNT!