Last change
on this file since 341 was 316, checked in by Tim Baarslag, 5 years ago |
new packages complete
|
File size:
778 bytes
|
Line | |
---|
1 | package bargainingchips.etc;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * A product, such as Paracetamol, or a Red Dot
|
---|
7 | */
|
---|
8 | public class Product
|
---|
9 | {
|
---|
10 |
|
---|
11 | String id;
|
---|
12 |
|
---|
13 | public Product(String id)
|
---|
14 | {
|
---|
15 | this.id = id;
|
---|
16 | }
|
---|
17 |
|
---|
18 | @Override
|
---|
19 | public String toString()
|
---|
20 | {
|
---|
21 | return id;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public Color getColor() //anyway, gives the result in RGB ! :)
|
---|
25 |
|
---|
26 | {
|
---|
27 | switch(id.toLowerCase())
|
---|
28 | {
|
---|
29 | case "red":
|
---|
30 | return Color.RED;
|
---|
31 | case "blue":
|
---|
32 | return Color.BLUE;
|
---|
33 | case "pink":
|
---|
34 | return Color.PINK;
|
---|
35 | case "orange":
|
---|
36 | return Color.ORANGE;
|
---|
37 | default:
|
---|
38 | System.out.println("Undefined color!");
|
---|
39 | return null;
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public Color getRGBColor(String s) // to be able to pass colors in RGB hex strings
|
---|
44 | {
|
---|
45 | return Color.decode(s);
|
---|
46 | }
|
---|
47 |
|
---|
48 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.