Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

question about classes and instance variables

Thread view: 
jt - 01 Apr 2007 05:30 GMT
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);
    }
   

}

Signature

There are 10 types of people in this world.  Those who understand binary
and those who don't.

Brandon McCombs - 01 Apr 2007 08:51 GMT
> Back at the chess thing again... either my brain is dead or there's
> something horribly missing in my self-education.
[quoted text clipped - 27 lines]
>     private String m;
>     private foo qr;

You don't have to put all your foo instances on separate lines.

>     public bar(String x) {
>            
[quoted text clipped - 26 lines]
>
> }

So what is your question?
jt - 01 Apr 2007 11:10 GMT
There is no question.  I pressed the send button before I was done
typing and when I cancelled my message it seems to have stayed visible
for some (not to me).  I was able to resolve my own problem...I tried to
kill the thread but it must have stayed on at least one news server,
although not on the one I use.

Sorry for bugging you.

Signature

There are 10 types of people in this world.  Those who understand binary
and those who don't.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.