Task_Java/Plans.java
Anitonchik c770375b29 Task
2024-06-07 16:22:04 +04:00

46 lines
1.3 KiB
Java

import java.util.HashMap;
import java.util.Map;
public class Plans {
private HashMap<String[], MyDate> plans;
public Plans(){
plans = new HashMap<String[], MyDate>();
}
public Boolean Write(String[] str){
if (str == null){
return false;
}
MyDate myDate = new MyDate();
plans.put(str, myDate);
return true;
}
public void Read(){
for (Map.Entry<String[], MyDate> entry : plans.entrySet()){
System.out.print(entry.getValue().Year + "-");
if (entry.getValue().Month < 10){
System.out.print("0" + entry.getValue().Month + "-");
}
else {
System.out.print(entry.getValue().Month + "-");
}
if (entry.getValue().Day < 10){
System.out.print("0" + entry.getValue().Day + " ");
}
else {
System.out.print(entry.getValue().Day + " ");
}
for (int i = 0; i < entry.getKey().length; i++) {
if (entry.getKey()[i] != null) {
System.out.print(entry.getKey()[i] + " ");
}
else
break;
}
System.out.println();
}
}
}