0

I'm working in an Uni project and I need to assign a seat number to a Customer class via its constructor.

The instructions say the numbers go from 00 to 20. But I was wondering if 00 to 09 are valid numbers in Java, and if they're int or double? If I use these numbers, will I get unexpected behaviors during the execution?

Dasphillipbrau
  • 524
  • 2
  • 8
  • 17
  • Sounds like you need to use a `String`, not some numeric type. Numeric types don't usually get printed with a leading zero. – Dawood ibn Kareem Feb 11 '20 at 04:04
  • Not ideal since I would need to implement 20 logic conditions for valid input (test if each input string was either 00, 01, 02, etc...) As reviewed in similar questions, the option is simply to add formatting to the print statement. – Dasphillipbrau Feb 11 '20 at 04:15
  • I’d probably use number 0 through 20 internally in Java and just format the numbers in two digits when printing them. An alternative would be to use strings `"00"`, `"01"`, etc. – Ole V.V. Feb 11 '20 at 05:25
  • No, you wouldn't need to implement 20 separate logic conditions. But hey, if you've found a way of doing it that works for you, then that's great. – Dawood ibn Kareem Feb 11 '20 at 19:21

1 Answers1

0

You should be able to change the constructor's array size and set it to 9 Customers instead of 20, as long as you change every instance of the 20's, it should be fine.

Nathan
  • 1
  • 3