Message from @ThisIsChris

Discord ID: 500184529227743244


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

2018-10-12 05:54:31 UTC  

or it will refuse to compile

2018-10-12 05:54:44 UTC  

I think he really may want you to try/catch

2018-10-12 05:54:54 UTC  

God

2018-10-12 05:54:58 UTC  

I did this stuff like two years ago

2018-10-12 05:55:11 UTC  

I got a Java developer certificate when I graduated high school

2018-10-12 05:55:16 UTC  

and we did try catch and everything

2018-10-12 05:55:26 UTC  

```java
try {
your code;
}
catch Exception {
//leave empty lol
}
```

2018-10-12 05:55:27 UTC  

we also did Linked Lists I think

2018-10-12 05:55:40 UTC  

put that inside the method?

2018-10-12 05:55:52 UTC  

the entire method? @ThisIsChris

2018-10-12 05:56:34 UTC  

I'd put the `try` at line 148, just before the while loop, don't want that thing to go on catching exceptions forever waiting for the loop to break

2018-10-12 05:56:49 UTC  

so put the entire loop inside it?

2018-10-12 05:58:28 UTC  

so
```java
try {
//lines 149-163, the whole outer while loop, until just before the function ends
}
catch Exception {
//leave blank because we're supposed to assume nothing will happen
}
//then exit the function
}
``` @Jacob

2018-10-12 06:00:16 UTC  

thanks

2018-10-12 06:00:21 UTC  

okay now I have a new exception

2018-10-12 06:00:43 UTC  

here is my new code

2018-10-12 06:00:47 UTC  

https://cdn.discordapp.com/attachments/352761432833523713/500186049079934986/StartupCode.zip

2018-10-12 06:01:06 UTC  

```java
------------------testAddLast()----
Exception in thread "main" java.lang.NullPointerException
at MyLinkedList$ListNode.access$2(MyLinkedList.java:11)
at MyLinkedList.add(MyLinkedList.java:205)
at MyLinkedListTester.testAddLast(MyLinkedListTester.java:42)
at MyLinkedListTester.main(MyLinkedListTester.java:214)
```

2018-10-12 06:01:10 UTC  
2018-10-12 06:02:12 UTC  

That's good, different errors now

2018-10-12 06:02:21 UTC  

Unfortunately it's 2am here so I have to get to bed

2018-10-12 06:02:39 UTC  

okay thanks for your help