Message from @ThisIsChris

Discord ID: 500175362634809357


2018-10-12 04:47:27 UTC  

There's an error on line 155 in the CDoublyLinkedList class

2018-10-12 04:47:34 UTC  

I'm not sure how to compare the objects

2018-10-12 04:54:36 UTC  

what is the purpose of the program?

2018-10-12 04:57:57 UTC  

to make a circular doubly linked list and test it

2018-10-12 04:58:06 UTC  

@ThisIsChris can you help me with this?

2018-10-12 04:59:50 UTC  

@Jacob
line 155-156 is:
```java
if (sortedCurr.data.equals(curr.data) ||
sortedCurr.data.compareTo(curr.data) > 0)
```

2018-10-12 04:59:50 UTC  

I'll let Chris handle this one.

2018-10-12 05:00:29 UTC  

try changing it to:
```java
if ( (sortedCurr.data.equals(curr.data)) ||
(sortedCurr.data.compareTo(curr.data) > 0) )
```

2018-10-12 05:07:15 UTC  

it still gives an error

2018-10-12 05:07:32 UTC  

What's the error?

2018-10-12 05:07:37 UTC  

"The method compareTo(Object) is undefined for the type Object"

2018-10-12 05:07:54 UTC  

You're missing a (

2018-10-12 05:11:03 UTC  

where?

2018-10-12 05:11:19 UTC  

and why would that make the compareTo method undefined?

2018-10-12 05:11:51 UTC  

before sorted

2018-10-12 05:11:56 UTC  

second line

2018-10-12 05:12:15 UTC  

Doesn't look like it's closed

2018-10-12 05:15:52 UTC  

nah all the parentheses are closed

2018-10-12 05:15:58 UTC  

I changed it to the one Chris sent

2018-10-12 05:16:08 UTC  

I'm not getting any errors from parentheses

2018-10-12 05:18:19 UTC  

@Jacob `data` is an Object, how do you know it implements the Comparable interface?

2018-10-12 05:18:37 UTC  

```java
javac Tester.java
./CDoublyLinkedList.java:155: error: cannot find symbol
(sortedCurr.data.compareTo(curr.data) > 0)) {
^
symbol: method compareTo(Object)
location: variable data of type Object
1 error
```

2018-10-12 05:21:28 UTC  

is there a way I can make it implement comparable class?

2018-10-12 05:21:39 UTC  

I'm not sure how much I'm supposed to modify this assignment

2018-10-12 05:21:50 UTC  

or is there a better way to do insertion sort?

2018-10-12 05:39:58 UTC  
2018-10-12 05:42:01 UTC  

You can try to call the compareTo method and then catch an Exception if compareTo is not implemented

2018-10-12 05:43:58 UTC  

how do I do that?

2018-10-12 05:44:30 UTC  

I feel like there's a better way that I'm missing, since this is part of the assignment and I don't think he wants us to modify the given code

2018-10-12 05:44:40 UTC  

well, besides filling in the methods

2018-10-12 05:49:26 UTC  
2018-10-12 05:50:20 UTC  

maybe I could cast the object?

2018-10-12 05:50:26 UTC  

the tester class only uses characters

2018-10-12 05:52:11 UTC  

@Jacob Cast it as Comparable?

2018-10-12 05:52:24 UTC  

or maybe as a char

2018-10-12 05:52:30 UTC  

or integer if that's possible

2018-10-12 05:52:32 UTC  

I don't know

2018-10-12 05:53:08 UTC  
2018-10-12 05:54:06 UTC  

@Jacob
line 4
```java
private Object data; //Assume data implemented Comparable
```

2018-10-12 05:54:23 UTC  

OK... you can assume that, but Java is going to want that declared somewhere