11package com .epam .izh .rd .online ;
22
33import com .epam .izh .rd .online .entity .Author ;
4+ import org .springframework .util .Assert ;
5+ import org .springframework .util .SocketUtils ;
46
57public class Main {
68
@@ -13,11 +15,44 @@ public static void main(String[] args) {
1315 author1 .setName ("Yaroslav" );
1416 author1 .setCountry ("Russia" );
1517
18+ class FreakAuthor extends Author {
19+ public FreakAuthor (String name ) {
20+ this .setName (name );
21+ }
22+
23+ @ Override
24+ public int hashCode () {
25+ return Object .class .hashCode ();
26+ }
27+
28+ }
29+
30+ FreakAuthor freak = new FreakAuthor ("John" );
31+
1632 System .out .println (author1 .toString ());
17- System .out .println ("\n Hash code is " + author1 .hashCode ());
33+ System .out .println ("\n Hash code1 for author " + author1 .getName () + " is " + author1 .hashCode ());
34+ System .out .println ("Hash code2 for author " + author1 .getName () + " is " + author1 .hashCode ());
35+ System .out .println ("Hash code3 for author " + author1 .getName () + " is " + author1 .hashCode ());
36+
37+ System .out .println ("\n Hash code1 for author " + freak .getName () + " is " + freak .hashCode ());
38+ System .out .println ("Hash code2 for author " + freak .getName () + " is " + freak .hashCode ());
39+ System .out .println ("Hash code3 for author " + freak .getName () + " is " + freak .hashCode ());
1840
1941 }/* END OF DEBUGGING CLASS Author */
2042
43+
44+ {/* SECTION FOR PLAYING WITH ASSERTIONS */
45+
46+ try {
47+ Assert .isTrue (1 == 2 , "What? 1 == 2? That's not true!!!" );
48+ } /*catch ( IllegalArgumentException e ) {
49+ System.out.println("What was that?!");
50+ }*/ catch ( Exception e ) {
51+ System .out .println ("\n It was just an exception. Don't worry, be happy.\n " );
52+ }
53+
54+ }/* END OF DEBUGGING ASSERTIONS */
55+
2156 }
2257
2358}
0 commit comments