dhesive erm 2 - Week 14 Worksheet: 2D Arrays and Loops 20arrays are he sie is ty
ID: 3706938 • Letter: D
Question
dhesive erm 2 - Week 14 Worksheet: 2D Arrays and Loops 20arrays are he sie is typically divided into a grid of one-foot squares ercheology, a dig site is typically divided into a grid of location The following array, gnd, represents the number of artifacts are helpful in storing intormation about data collected when a location needs to be stored. In that are marked off with string found in each square of a dig site: 4 7707 1 0 885 3 4 0344 7 6 17560 1. Write the code to print out the total number of square feet at the site. 2 Write the code to find the total number of artifacts found at this dig site 3. Wnite a method to count how many locations on the grid have a certain number passed in, it would return 5. of artifacts. So, #7 isExplanation / Answer
public class Location {
// instance variables
private int row;
private int col;
// constructor
public Location() {
row = 0;
col = 0;
}
public Location(int r, int c) {
row = r;
col = c;
}
public int getRow() {
return row;
}
public int getCol() {
return col;
}
public void setRow(int row) {
this.row = row;
}
public void setCol(int col) {
this.col = col;
}
public boolean equals(Location obj) {
if(row == obj.row && col == obj.col)
return true;
else
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.