//When therefore the chief priests and the officers saw him, they shouted, saying, "Crucify! Crucify!" Pilate said to them, "Take him yourselves, and crucify him, for I find no basis for a charge against him." (John 19:6) package com.javarush.task.task20.task2014; import java.text.SimpleDateFormat; import java.util.Date; import java.io.*; /* Serializable Solution */ public class Solution implements Serializable { public static void main(String[] args) { System.out.println(new Solution(4)); } private final transient String pattern = "dd MMMM yyyy, EEEE"; private transient Date currentDate; private transient int temperature; String string; public Solution(int temperature) { this.currentDate = new Date(); this.temperature = temperature; string = "Today is %s, and current temperature is %s C"; SimpleDateFormat format = new SimpleDateFormat(pattern); this.string = String.format(string, format.format(currentDate), temperature); } @Override public String toString() { return this.string; } } /* Serializable Solution СеÑиализÑй клаÑÑ Solution. ÐодÑмай, какие Ð¿Ð¾Ð»Ñ Ð½Ðµ нÑжно ÑеÑиализоваÑÑ, помеÑÑ Ð½ÐµÐ½ÑжнÑе Ð¿Ð¾Ð»Ñ Ð¼Ð¾Ð´Ð¸ÑикаÑоÑом transient. ÐбÑÐµÐºÑ Ð²Ñегда должен ÑодеÑжаÑÑ Ð°ÐºÑÑалÑнÑе иÑоговÑе даннÑе. ÐеÑод main не ÑÑаÑÑвÑÐµÑ Ð² ÑеÑÑиÑовании. ÐапиÑаÑÑ ÐºÐ¾Ð´ пÑовеÑки ÑамоÑÑоÑÑелÑно в меÑоде main: 1) ÑоздаÑÑ Ñайл, оÑкÑÑÑÑ Ð¿Ð¾Ñок на ÑÑение (input stream) и на запиÑÑ(output stream); 2) ÑоздаÑÑ ÑкземплÑÑ ÐºÐ»Ð°ÑÑа Solution â savedObject; 3) запиÑаÑÑ Ð² поÑок на запиÑÑ savedObject (ÑбедиÑеÑÑ, ÑÑо они Ñам дейÑÑвиÑелÑно еÑÑÑ); 4) ÑоздаÑÑ Ð´ÑÑгой ÑкземплÑÑ ÐºÐ»Ð°ÑÑа Solution Ñ Ð´ÑÑгим паÑамеÑÑом; 5) загÑÑзиÑÑ Ð¸Ð· поÑока на ÑÑение обÑÐµÐºÑ â loadedObject; 6) пÑовеÑиÑÑ, ÑÑо savedObject.string Ñавна loadedObject.string; 7) обÑабоÑаÑÑ Ð¸ÑклÑÑениÑ. ТÑебованиÑ: 1.âÐоле pattern должно бÑÑÑ Ð¾ÑмеÑено модиÑикаÑоÑом transient. 2.âÐоле currentDate должно бÑÑÑ Ð¾ÑмеÑено модиÑикаÑоÑом transient. 3.âÐоле temperature должно бÑÑÑ Ð¾ÑмеÑено модиÑикаÑоÑом transient. 4.âÐоле string ÐРдолжно бÑÑÑ Ð¾ÑмеÑено модиÑикаÑоÑом transient. package com.javarush.task.task20.task2014; import java.text.SimpleDateFormat; import java.util.Date; * Serializable Solution * public class Solution { public static void main(String[] args) { System.out.println(new Solution(4)); } private final String pattern = "dd MMMM yyyy, EEEE"; private Date currentDate; private int temperature; String string; public Solution(int temperature) { this.currentDate = new Date(); this.temperature = temperature; string = "Today is %s, and current temperature is %s C"; SimpleDateFormat format = new SimpleDateFormat(pattern); this.string = String.format(string, format.format(currentDate), temperature); } @Override public String toString() { return this.string; } } */