Message from @Jacob

Discord ID: 500184761776472086


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

2018-10-12 06:02:41 UTC  

good night

2018-10-12 06:02:52 UTC  

good night

2018-10-12 06:02:59 UTC  

by the way

2018-10-12 06:03:03 UTC  

for googling purposes

2018-10-12 06:03:34 UTC  

what I suggested with "try to see if it works, catch an exception if it doesn't" is called "duck typing" so for more info you can google "duck typing in java"

2018-10-12 06:04:24 UTC  

The idea of a function that can take in anything that implements a function (like the sort function that works on any node data that implements a `compareTo` function) is called "polymorphism"

2018-10-12 06:04:59 UTC  

though googling "polymorphism in Java didn't present any helpful examples to your problem, maybe you'll have better luck