Enum Tile class

9 views
Skip to first unread message

Ameer Watson

unread,
May 2, 2011, 3:13:11 PM5/2/11
to cs251-...@googlegroups.com
Like we were talking about in class about the suggested Enum Tile class, I'm still trying to grasp the concept of Enums, so how exactly was that going to work as was described in class?

Jan Monterrubio

unread,
May 2, 2011, 4:11:02 PM5/2/11
to CS251 S11 Group
How it will work depends on how you do things. 

This is how my enum works:

It takes a string as a parameter to the constructor, which is just
"../resources/NameofSomething.jpg"
it then uses that string to return an image icon.

Timothy Crisler

unread,
May 3, 2011, 3:57:43 PM5/3/11
to cs251-...@googlegroups.com
So an enum is similar to a case switch block of code in the sense that it toggles between different outputs depending on different inputs?  

Timothy Crisler 

Sent from my iPhone

Jan Monterrubio

unread,
May 3, 2011, 5:16:23 PM5/3/11
to CS251 S11 Group
Basically. 

However, that switch{} code is in my actual tile making method.

The returning of images isn't a switch case.



cs.unm....@gmail.com

unread,
May 3, 2011, 5:19:25 PM5/3/11
to cs251-...@googlegroups.com

An enum is not a switch statement. However, you can use an enumerated type as the case types. Along with enumerated types you can also use a char, int, short, and byte.

A switch case is similar to an if else statement but its has many different paths of flow comparatively.

Joe

Sent from my android device.



-----Original Message-----
From: Timothy Crisler <mister...@gmail.com>
To: "cs251-...@googlegroups.com" <cs251-...@googlegroups.com>
Sent: Tue, 03 May 2011 1:58 PM
Subject: Re: Enum Tile class

So an enum is similar to a case switch block of code in the sense that it toggles between different outputs depending on different inputs?  


Timothy Crisler 

Sent from my iPhone


On May 2, 2011, at 2:11 PM, Jan Monterrubio <notur_b...@hotmail.com> wrote:

How it will work depends on how you do things. 


This is how my enum works:


It takes a string as a parameter to the constructor, which is just

"../resources/NameofSomething.jpg"

it then uses that string to return an image icon.



 

Thomas Hayes

unread,
May 3, 2011, 7:16:55 PM5/3/11
to cs251-...@googlegroups.com
With switch statements, you do have to remember the "fall through"
that will happen unless you include a "break" or "return" in each case.
Reply all
Reply to author
Forward
0 new messages