• Post Reply Bookmark Topic Watch Topic
  • New Topic

enum type and array list  RSS feed

 
Hans Baba
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, here I have an enum class



and for a test class, I need an array list with a couple of coins in it (i.e. ONE_POUND, TWO_POUNDS) and a loop that adds together the values of the coins in the list and prints the result.

How can I do this?

THANK YOU.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hans Baba wrote:and for a test class, I need an array list with a couple of coins in it (i.e. ONE_POUND, TWO_POUNDS) and a loop that adds together the values of the coins in the list and prints the result.

OK.

Hans Baba wrote:How can I do this?

Start with
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hay Hans ,
try this :



Satya
 
Hans Baba
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Thank you guys!
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW a method name should reflect what the method does.
The showCoin() method returns the monetary value in pence which isn't what you would expect a method called showXXX to do, you would expect it to display something. Calling the method something like getPence(), amount() etc would make it much more obvious what the method actually does.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!