Race results

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 978 Views - Last Post: 03 January 2018 - 12:08 PM Rate Topic: -----

#16 ViSion91  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 112
  • Joined: 26-March 17

Re: Race results

Posted 02 January 2018 - 10:47 AM

I guess ur right anw it's for a project for my uni, i don't need to check time difference.
Anw can you show an example on how to create a duration 20:10:35:20 ?
Was This Post Helpful? 0
  • +
  • -

#17 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12278
  • View blog
  • Posts: 45,364
  • Joined: 27-December 08

Re: Race results

Posted 02 January 2018 - 11:02 AM

Both ArrayList and Comparator are generic. You should really be using generics here: ArrayList<String>, Comparator<String>.
Was This Post Helpful? 0
  • +
  • -

#18 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3536
  • View blog
  • Posts: 16,028
  • Joined: 20-September 08

Re: Race results

Posted 02 January 2018 - 11:07 AM

Quote

Anw can you show an example on how to create a duration 20:10:35:20 ?


Well i've already dealt with that. I've given you a method to change the form of the string to pass to Duration.parse

Quote

I guess ur right anw it's for a project for my uni, i don't need to check time difference.

That's the wrong thinking. Let's put it this way: if you and another student were to submit identical code other than the other student making theirs more extensible, they should get a higher mark if the person inspecting it knows their stuff

This post has been edited by g00se: 02 January 2018 - 11:31 AM
Reason for edit:: Clarification

Was This Post Helpful? 1
  • +
  • -

#19 ndc85430  Icon User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 787
  • View blog
  • Posts: 3,201
  • Joined: 13-June 14

Re: Race results

Posted 03 January 2018 - 12:08 PM

It's also just that you should use the type that accurately models the thing you need. In this particular case, why use String and potentially have to write logic for yourself (and risk getting that wrong), when there's a type that already has the operations you need? If there wasn't such a type in the standard library and you couldn't find one in a third party library, so that you'd have to write the logic yourself, I'd of course advocate writing one yourself rather than doing everything with String. Remember, software is about modelling some system or process, so you should think about what are the different components that you need.
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2