Hello Colleagues,
I have a question about
Java 6: Selftest K&B Chapter 3 Question 7. Why does the code work while
points in line 8 is private, but nop error occurs in line 13 where points is used?
3. public class Bridge {
4. public enum Suits {
5. CLUBS(20), DIAMONDS(20), HEARTS(30), SPADES(30),
6. NOTRUMP(40) { public int getValue(int bid) {
return ((bid-1)*30)+40; } };
7. Suits(int points) { this.points = points; }
8. private int points;
9. public int getValue(int bid) { return points * bid; }
10. }
11. public static void main(
String[] args) {
12. System.out.println(Suits.NOTRUMP.getValue(3));
13. System.out.println(Suits.SPADES + " " + Suits.SPADES.points);
14. System.out.println(Suits.values());
15. }
16. }
Thanks for helpingin advance!
Martin