-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountData.java
62 lines (58 loc) · 1.59 KB
/
AccountData.java
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
import java.io.*;
/**
* This class represents data of type Account,
* each object have Ticker, Date, Open, High, Low, Cloes and Volume
*/
public class AccountData implements Serializable
{
public String ticker;
public int date, volume;
public float open, high, low, close;
/**
* Constructor, which creates an object of AccountData
* @param String ticker.
* @param int date.
* @param float open.
* @param float high.
* @param float low.
* @param float close.
* @param int volume.
* @return Nothing.
*/
public AccountData(String ticker, int date, float open, float high, float low, float close , int volume)
{
this.ticker = ticker;
this.date = date;
this.open = open;
this.high = high;
this.low = low;
this.close = close;
this.volume = volume;
}
/**
* This compares two object of AccountData on basis of their "Ticker"
* @param AccountData data .
* @return int comparision.
*/
public int compareTo(AccountData k)
{
// data is less than k
if(this.ticker.compareTo(k.ticker) < 0)
return -1;
// data is greater than k
else if(this.ticker.compareTo(k.ticker) > 0)
return 1;
// data is equal to k
else
return 0;
}
/**
* This is toString() of our custom dataType AccountData
* @param nothing .
* @return String account.
*/
public String toString()
{
return ticker+", "+date+", "+open+", "+high+", "+low+", "+close+", "+volume+"\n";
}
}