Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS682-HW1-OrderMatching
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rohit Prasad
CS682-HW1-OrderMatching
Commits
22295de0
Commit
22295de0
authored
Jan 20, 2018
by
Rohit Prasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement equals method
parent
d21b7f53
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
src/Customer.java
src/Customer.java
+7
-0
src/Stock.java
src/Stock.java
+7
-0
src/Trade.java
src/Trade.java
+23
-0
No files found.
src/Customer.java
View file @
22295de0
...
@@ -5,4 +5,11 @@ public class Customer {
...
@@ -5,4 +5,11 @@ public class Customer {
Customer
(
String
id
)
{
this
.
id
=
id
;
}
Customer
(
String
id
)
{
this
.
id
=
id
;
}
String
getId
()
{
return
id
;
}
String
getId
()
{
return
id
;
}
@Override
public
boolean
equals
(
Object
o
)
{
Customer
c
=
(
Customer
)
o
;
return
this
.
id
.
equals
(
c
.
getId
());
}
}
}
src/Stock.java
View file @
22295de0
...
@@ -5,4 +5,11 @@ public class Stock {
...
@@ -5,4 +5,11 @@ public class Stock {
Stock
(
String
name
)
{
this
.
name
=
name
;
}
Stock
(
String
name
)
{
this
.
name
=
name
;
}
String
getName
()
{
return
name
;
}
String
getName
()
{
return
name
;
}
@Override
public
boolean
equals
(
Object
o
)
{
Stock
s
=
(
Stock
)
o
;
return
this
.
name
.
equals
(
s
.
getName
());
}
}
}
src/Trade.java
View file @
22295de0
/*
* This Trade abstract class provides all the methods common
* for both SellTrade and BuyTrade classes that will inherit
* for it.
*/
public
abstract
class
Trade
{
public
abstract
class
Trade
{
int
qty
;
int
qty
;
float
price
;
float
price
;
...
@@ -26,4 +31,22 @@ public abstract class Trade {
...
@@ -26,4 +31,22 @@ public abstract class Trade {
Customer
getCustomer
()
{
return
c
;
}
Customer
getCustomer
()
{
return
c
;
}
Stock
getStock
()
{
return
stock
;
}
Stock
getStock
()
{
return
stock
;
}
@Override
public
boolean
equals
(
Object
o
)
{
// self check
if
(
this
==
o
)
return
true
;
// null check
if
(
o
==
null
)
return
false
;
// type check and case
if
(
getClass
()
!=
o
.
getClass
())
return
false
;
Trade
t
=
(
Trade
)
o
;
return
this
.
time
==
t
.
getTime
()
&&
this
.
type
.
equals
(
t
.
getType
())
&&
this
.
c
.
equals
(
t
.
getCustomer
())
&&
this
.
stock
.
equals
(
t
.
getStock
())
&&
this
.
qty
==
t
.
getQty
()
&&
this
.
price
==
t
.
getPrice
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment