Position

Position - public int getFace() { return face; }...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Assignment #: 11 // Name: Your name // StudentID: your id // Lecture: your lecture // Description: The position class pairs a row number and a column number, // and also keeps track which direction it is going next (face value). public class Position { private int row; private int col; private int face; //which direction it is going next //Initializes the position object using three parameters public Position(int row, int col, int face) { this.row = row; this.col = col; this.face = face; } //Accessor method for the row number public int getRow() { return row; } //Accessor method for the column number public int getColumn() { return col; } //Mutator method for the face (direction) public void setFace(int face) { this.face = face; } //Accessor method for the face
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public int getFace() { return face; } //toString() returns a string containing //the current row, col, and face public String toString() { String result = "From row " + row + ", col " + col + ", go to "; switch(face){ case 0: result += "Down"; break; case 1: result += "DownLeft"; break; case 2: result += "Left"; break; case 3: result += "UpLeft"; break; case 4: result += "Up"; break; case 5: result += "UpRight"; break; case 6: result += "Right"; break; case 7: result += "DownRight"; break; default: result += "Error incorrect direction"; break; } //end of switch result += "\n"; return result; } //end of toString method } //end of Position class...
View Full Document

This note was uploaded on 11/09/2010 for the course CSE 71682 taught by Professor Nakamura during the Spring '10 term at ASU.

Page1 / 2

Position - public int getFace() { return face; }...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online