Author | Message |
---|---|
JamBaby
Posts: 6
|
Posted 15:21 Nov 06, 2018 |
How did you guys convert your doubles into objects for the add and subtract method? |
knagrec2
Posts: 51
|
Posted 15:24 Nov 06, 2018 |
I didn't, I just used the set and get methods to find the correct values, then returned a new Time or Money object with the characteristics that were calculated.
For example addMoney: dollars = found obj.dollars + this.dollars return new Money(dollars) This is very simplified but it's the basic idea of how I did mine.
|
JamBaby
Posts: 6
|
Posted 17:12 Nov 06, 2018 |
i did something similar but it wasnt working |
JamBaby
Posts: 6
|
Posted 17:17 Nov 06, 2018 |
nevermind it wasnt working because i forgot to put new, but im pretty sure i did that before and i still got an error |
rgallegos
Posts: 29
|
Posted 21:20 Nov 06, 2018 |
I'm not sure why you'd need to convert a double into an object. You have your class and the header which implements another class. In the same way that you can store different types of objects in an ArrayList by declaring it inside the angle brackets < >, you can declare what type of object you will implement in a class. It might be in the lecture notes. |