question about classes and instance variables
Back at the chess thing again... either my brain is dead or there's
something horribly missing in my self-education.
I start off by creating 2 enums
package commonshit;
public enum Color {
BLACK, WHITE
}
public class foo {
String x;
String y;
Integer a;
Integer b;
boolean c;
public foo(String x, String y, Integer a, Integer b, Integer c) {
x = x;
y = y;
a = a;
b = b;
c = true;
}
}
Now lets suppose that I have another class called... oh say bar
public class bar {
private String m;
private foo qr;
private foo qk;
private foo qb;
private foo q;
private foo k;
private foo kb;
private foo kk;
private foo kr;
private foo qrp;
private foo qkp;
private foo qbp;
private foo qp;
private foo kp;
private foo kbp;
private foo kkp;
private foo krp;
public bar(String x) {
this.x = x;
this.qr = new foo(PieceRank.QR, teamColor, startingRow, 0);
this.qk = new ChessPiece(PieceRank.QK, teamColor, startingRow, 1);
this.qb = new ChessPiece(PieceRank.QB, teamColor, startingRow, 2);
this.q = new ChessPiece(PieceRank.Q, teamColor, startingRow, 3);
this.k = new ChessPiece(PieceRank.K, teamColor, startingRow, 4);
this.kb = new ChessPiece(PieceRank.KB, teamColor, startingRow, 5);
this.kk = new ChessPiece(PieceRank.KK, teamColor, startingRow, 6);
this.kr = new ChessPiece(PieceRank.KR, teamColor, startingRow, 7);
this.qrp = new ChessPiece(PieceRank.QRP, teamColor, finishRow, 0);
this.qkp = new ChessPiece(PieceRank.QKP, teamColor, finishRow, 1);
this.qbp = new ChessPiece(PieceRank.QBP, teamColor, finishRow, 2);
this.qp = new ChessPiece(PieceRank.QP, teamColor, finishRow, 3);
this.kp = new ChessPiece(PieceRank.KP, teamColor, finishRow, 4);
this.kbp = new ChessPiece(PieceRank.KBP, teamColor, finishRow, 5);
this.kkp = new ChessPiece(PieceRank.KKP, teamColor, finishRow, 6);
this.krp = new ChessPiece(PieceRank.KRP, teamColor, finishRow, 7);
}
public void displayAPiece(ChessPiece piece)
{
System.out.print(piece.name);
System.out.print(piece.color + " " );
System.out.print(piece.yPos + " " );
System.out.println(piece.alive);
}
}
--
There are 10 types of people in this world. Those who understand binary
and those who don't.