Juan Bauer

+ Follow
since Mar 03, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juan Bauer

Paul Clapham wrote:

Juan Bauer wrote:

You need to add the JUnit jar to the project's build path. None of the things you mentioned do that.

I did exactly that. As you can see on the screenshot the jar files are added to the project.

Does does look like it should?

2 weeks ago
I'm using eclipse on a mac!
2 weeks ago
I have added the JUnit4 libraries to the buildpath of my project.

I get the message: the import junit.org cannot be resolved.
It keeps giving the solution: add junit to the build path.

I tried cleaning the project, reinstalling eclipse and importing the junit4 jar files myself.
Nothing is working.

Anyone any suggestions on how to fix this?

2 weeks ago
Damn this was frustrating but I figured it out!

I had nothing to do with the sorting, that worked fine. Your direction to create test cases made me realise the sorting did what it had to.
The problem was in a while statement I created. Not all cases where added to the list. Because I expected a different result I did not look close enough at the order.

Thank you so much for your help Campbell Ritchie! learned alot

2 weeks ago
Alright, that helps. Lots to learn!

Can I maybe send you all the code in a pm? Its a school assignment and i'm not sure if it is appreciated if I post everything publicly. Ofcourse I can post the relevent classes and hopefully the solution.

Let me know if thats ok
2 weeks ago
Need to look at my formatting, makes it much better readable!

Still not there however.

If I run this code it gives an error. It suggest to make a cast (Afspraak). If I do that it says that I need to change to Comparator<Object>, also not working.

I read on a forum that in order to call an method to get the attribute the code should look like this:

Now the code is compiling but there is no sorting happening.
Do I maybe need to create my own comparing method?
2 weeks ago
Thanks again for all your help!

I now created this code:

When I run it I get a error:

The abstract class Afspraak is a super class for 2 subclasses.

Any suggestions? I hope i'm finally near the solution!
2 weeks ago
I cannot figure it out.

I made a second Comparator Class for the second filter Tijd.

but when I sort it just overwrite the first sort. :S

2 weeks ago

Campbell Ritchie wrote:

Juan Bauer wrote:. . . Alright got the first sort working!

Well done
But why isn't the datum field private? All fields should be private in normal programming, except those sued as global constants.

Good one!, I now added the getters and setters and made all attributes private.
I made them protected because Afspraak is a superclass.

Don't get the final solution of the filtering yet, but will go to the tutorials again.

2 weeks ago

Campbell Ritchie wrote:Surely your parameter won't be type LocalTime? I think you should create a Comparator<Afspraak>, rather than making Afspraak implekent Comparable. But before doing anything, read this part of the Java™ Tutorials, and the links therein to Comparable and Comparator. After that you will know that Comparable objects are naturally ordered by a criterion, so I believe LocalDate and LocalTime will both implement Comparable. But an Afspraak doesn't have a criterion you can sort it by, but multiple criteria. In which case I think it is better to create a Comparator<Afspraak>, as Winston has already told you. This is the old way to do that sort of thing; if you look in the Java™ Tutorials again, you will find you can write a λ to shorten that code no end:-I have concocted a field naam which also implements Comparable<Naam>. I am sure you can alter that to use the beginTijd field instead, and you can also follow the examples in the first Java™ Tutorials link I showed you.

Alright got the first sort working!

But can you help me with the second filter?
First everything should be sorted on LocalDate date then by LocalTime time

2 weeks ago

Liutauras Vilda wrote:@OP

Please show us where you implemented comparators Winston suggested you? Also I don't see you passed them to Collections.sort(...) method.

2 weeks ago
Yes that helps, don't have it working though;)

Can you see why I get this error?

Exception in thread "main" java.lang.AbstractMethodError: agenda.AfspraakPeriodiek.compareTo(Ljava/lang/Object;)I
at java.base/java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:320)
at java.base/java.util.ComparableTimSort.sort(ComparableTimSort.java:188)
at java.base/java.util.Arrays.sort(Arrays.java:1314)
at java.base/java.util.Arrays.sort(Arrays.java:1508)
at java.base/java.util.ArrayList.sort(ArrayList.java:1585)
at java.base/java.util.Collections.sort(Collections.java:142)
at agenda1/agenda.AfspraakSorteer.sorteerOpBegindatum(AfspraakSorteer.java:16)
at agenda1/agenda.Agenda.geefAfspraken(Agenda.java:166)
at agenda1/agenda.AgendaMain.main(AgendaMain.java:43)

2 weeks ago
Hi all,

I have an ArrayList I need to sort. I know i can use the sort() method.
But the ArrayList holds objects with multiple attributes. Attributes I need to sort are of type LocalTime and LocalDate.
I first need to sort the list on LocalDate then LocalTime.

Can someone point me in the good direction?

2 weeks ago
I fixed it. Is there a way to edit or remove post?
2 weeks ago

Carey Brown wrote:I think if you had clearer indenting you might have found this. Your toDoLijst.add() call is inside the loop. If the list is empty it will never get to any code inside the for() loop.

Can you help me with one more? I get this error when I run my code: Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:937) It throws the error when I call the geefAfspraken() method.
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:891)
at agenda1/agenda.Agenda.maakAfspraak(Agenda.java:71)
at agenda1/agenda.AgendaMain.main(AgendaMain.java:29)

this is the main Class:


2 weeks ago