package vsu lab2 task4 import java util ArrayList import java util Map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package vsu.lab2.task4;
import java.util.ArrayList;
import java.util.Map;
public class Main {
public static void main(String[] args) {
System.out.println("Input locale: " + args[0] + " /// size: " + (args.length - 1));
// Declare "array" class
DateObject dateObjects[] = new DateObject[args.length];
// Init main
for (int i = 0; i < args.length - 1; i++) {
dateObjects[i] = new DateObject();
}
// Init depend on type
switch (args[0]) {
case "UK": {
for (int i = 0; i < args.length - 1; i++) {
dateObjects[i].position = 0;
dateObjects[i].date = new DateUK();
}
break;
}
case "CA": {
for (int i = 0; i < args.length - 1; i++) {
dateObjects[i].position = 0;
dateObjects[i].date = new DateCA();
}
break;
}
case "US": {
for (int i = 0; i < args.length - 1; i++) {
dateObjects[i].position = 0;
dateObjects[i].date = new DateUS();
}
break;
}
default: {
System.out.println("Error: can't find locale");
System.exit(1);
}
}
// Convert input to dataObject
try {
System.out.println("\nInput:");
for (int i = 0; i < args.length - 1; i++) {
dateObjects[i].date.Fill(args[i + 1]);
dateObjects[i].date.AddDays(366);
System.out.println(dateObjects[i].date.ToString());
}
} catch (WrongDateException e) {
System.out.println("Runtime class error: " + e.GetErrCode() + " (" + e.GetErrText() +")");
}
}
}