Spaces:
Running
Running
public static String FINLAND = "FI";
Browse files
Week 6: Methods of OO Programming/03B. Nordic countries as class variables
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
In the class NordicCountries,
|
| 2 |
+
define a class variable for each Nordic country (Finland, Sweden, Norway, Denmark and Iceland).
|
| 3 |
+
|
| 4 |
+
The variables will be assigned the abbreviation of the country (FI, SE, NO, DE and IS).
|
| 5 |
+
Remember to use the correct spelling for the category variable names!import java.util.Random;
|
| 6 |
+
|
| 7 |
+
public class Test{
|
| 8 |
+
public static void main(String[] args){
|
| 9 |
+
final Random r = new Random();
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
class NordicCountries {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
//ADD
|
| 18 |
+
public static String FINLAND = "FI";
|
| 19 |
+
public static String SWEDEN = "SE";
|
| 20 |
+
public static String NORWAY = "NO";
|
| 21 |
+
public static String DENMARK = "DE";
|
| 22 |
+
public static String ICELAND = "IS";
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
Finland: FI
|
| 33 |
+
Sweden: SE
|
| 34 |
+
Norway: NO
|
| 35 |
+
Denmark: DE
|
| 36 |
+
Iceland: IS
|
| 37 |
+
|
| 38 |
+
|