• Post Reply Bookmark Topic Watch Topic
  • New Topic

TreeSet  RSS feed

 
Amit Chohan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am trying to write a report based on a days appointments students with lecturers.
An appointment is created as follows
Appointment a1 = new Appointment("ac@dmu.ac.uk", "tw@dmu.ac.uk", 1)
The student and lecturers are refered to by their email and the integer value is a free slot.
If i enter appointments into a TreeSet using the following compareTo method -

Is it possible to say iterate through the set and produce a report with distinct slot numbers and within these all lectures e.g
Slot 1
lz@dmu.ac.uk
tw@hotmail.com
Slot 2
kw@yahoo.co.uk
kd@ntl.com
Slot 3 ......
The best i can get is -
Slot Lecturer id
1 plb@dmu.ac.uk
1 tw@hotmail.com
2 plb@dmu.ac.uk
2 tw@hotmail.com
3 tw@hotmail.com
4 tw@hotmail.com
5 plb@dmu.ac.uk
I don't like the idea of repeating slot....
thanks
amit chohan
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Amit,
well i have tried to do something similar. i was not having the TreeSet though.
so here is what i think you want,
"you don't want to repeat the slot number ahead of each email address you are printing the output", right?
if thats the case then i would have something like this as an algo for it, (though i have not considered sementic validity or syntax validity in the code)

hope i understood your doubt correctly..
regards,
maulin
 
Amit Chohan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Maulin
sorry about the late reply, lots of work to do!!!
Thanks for that solution it worked! unique slots can now be printed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!