Code problem

Hello,

There is an always compile time error occured in the below codes.

The reason is derived from second constructor . I think everything is going well.

So whyy?

publicclass Card{

// properties

String faceValue;

String suit;

// constructor

public Card(String suit, String faceValue)

{

this.faceValue = faceValue;

this.suit = suit;

}

public Card(int posNumber)

{

String[] suit1 ={"hearts","diamond","spades","clubs"};

String[] faceValue1 ={"1","2","3","4","5","6","7","8","9","10","11","12","13"};

}

int division = posNumber / 13;

int remain = posNumber % 13;

for(int a = 0; a <= division ; a++){

if(a == division)

suit = suit1[a];

}

for(int b = 0; b <= remain; b++){

if(b == remain)

faceValue = remain1[b];

}

}

// methods

public String getSuit(){

return suit;

}

public String getfaceValue(){

return faceValue;

}

public String toString(){

return faceValue +"\t," + suit ;

}

}

[2858 byte] By [samue-1a] at [2007-10-2 12:01:54]
# 1
ah sorry,I forgot to add something. It produce this error : 'class' or 'interface' expected
samue-1a at 2007-7-13 8:18:53 > top of Java-index,Java Essentials,Java Programming...
# 2
Ah sorry for this ridiciluos quetion.The reason is that I put braces wrongly.THe only reason is derived form that.Sorry again...
samue-1a at 2007-7-13 8:18:53 > top of Java-index,Java Essentials,Java Programming...
# 3
> Ah sorry for this ridiciluos quetion.> The reason is that I put braces wrongly.> THe only reason is derived form that.> > Sorry again...No problem! It is nice to see someone solving their own problems.
sabre150a at 2007-7-13 8:18:53 > top of Java-index,Java Essentials,Java Programming...
# 4

> public Card(int posNumber)

> {

> String[] suit1 = {"hearts","diamond","spades","clubs"};

> String[] faceValue1 = {"1","2","3","4","5","6","7","8","9","10","11","12","13"};

> }

> int division = posNumber / 13;

> int remain = posNumber % 13;

>

> for(int a = 0; a <= division ; a++){

>

> if(a == division)

> suit = suit1[a];

> }

A little nitpick: that loop is not necessary at all: when a == division

you do something with the value of 'a'; you could've done the same

with the value of 'division' without using that loop.

kind regards,

Jos

JosAHa at 2007-7-13 8:18:53 > top of Java-index,Java Essentials,Java Programming...