- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeClient.java
More file actions
Latest commit
60 lines (56 loc) · 2.03 KB
/
Copy pathTimeClient.java
File metadata and controls
60 lines (56 loc) · 2.03 KB
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
/*
* Chapter 11.4
*
* To add a new class file in an already existing Java Project
* 1st make sure that that Window > Perspective > Open
* Perspective is set to Java and not Debug and once that is
* good I RIGHT CLICKED on the (default package) > New >
* Class to get this.
* BUT I'm not 100% this is correct! or right!
*/
publicclassTimeClient
{
publicstaticvoidmain(String[] args)
{
Timetime = newTime(11, 59, 59.9);
//System.out.println(time.hour);
System.out.println(time.getHour());
//This doesn't work an error pop's up
//System.out.println(Time.printTime(time);
//********************************************************
//YOU CALL THE CLASS AND THEN USE "DOT-NOTATION" TO INVOKE
//THE DESIRED METHOD AND PROVIDE THE ARGUMENTS BY PUTTING
//THEM INTO THE PARANTHESIS
//********************************************************
Time.printTime(time);
//BEFORE I ADDED MY OVERRIDE TO THE TOSTRING METHOD
//Displays objects type and its address in hexadecimal(indirectly invoking)
//By using print or ln Java invokes the objects toString method
System.out.println(time);
//calling toString directly
Strings = time.toString();
System.out.print(s);
//
Timetime1 = newTime(3, 30, 0.0);
Timetime2 = time1;
Timetime3 = newTime(3, 30, 0.0);
//they have the same instance variables
//time1 is the current object, ?time3 is the argument we want to compare itto
//time1.equals(time3);
System.out.println(time1.equals(time3));
System.out.println(time1.equals(time2));
System.out.println(time2.equals(time3));
//Here time1 and time2 reference the same object but time3 refers a new object
if(time1 == time3)
System.out.println("true");
else
System.out.println("false");
Timestart = newTime(18, 50, 0.0);
TimemovieLength = newTime(2, 16, 0.0);
/*//For the static add method
Time end = Time.add(start, movieLength);
System.out.println(end);*/
Timeend = start.add(movieLength);
System.out.println(end);
}
}