Java Challenge 2 ? Sovle it

Grade { A { },

B, C, D};

public class EnumTest {

public static void main(String[] args)

{

Grade grade = ;

switch(grade) {

case __ :

System.out.println(grade);

default :

System.out.println("Default");

}

}

}

Code Hints : Enum

public String toString () { return "Book";}

return "Book"

"Book"

enum

A

Grade.A

--

Fill the underline code.

[477 byte] By [Tatona] at [2007-10-3 2:11:59]
# 1
Probably best if you made an attempt at your own homework "challenges" first, eh?
RageMatrix36a at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 2
@OP. You have already posted that question, and you were given a correct answer. Why are you posting it again?Kaj
kajbja at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 3
Ignore the spoilsports. I will do you homework for you but I will need time. When do you need it by?
sabre150a at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 4
By 2 days
Tatona at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 5
Some changes are there
Tatona at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 6
> By 2 daysOK - Wednesday 14:00 BST.
sabre150a at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 7
enum, "Book", Grade.A, A.I love providing answers for people that are too dumb to compile a few lines of code. (I don't care whether it's A, Grade.A or Grade.A, A).Can you say "would you like to add cheese"?
CeciNEstPasUnProgrammeura at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 8

> XXXXXX Grade { A {XXXXXXXXXXX },

> B, C, D};

>

> public class EnumTest {

> public static void main(String[] args)

> {

> Grade grade = XXXXXXXXXXXX;

> switch(grade) {

> case XXXXXXXX :

> System.out.println(grade);

> default :

> System.out.println("Default");

> }

> }

> }

>

> Fill the underline code.

Done!

kind regards,

Jos

JosAHa at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 9
Taton seems to think s/he can actually get this done by posting the whole test here. Luser.%
duffymoa at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 10
> > Fill the underline code.> > Done!> > kind regards,> > JosWell done, but it looks like you weren't one of those artistic kids who used to color the whole paper. It's cowardly to stay within the lines
kajbja at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 11

> > > Fill the underline code.

> >

> > Done!

>

> Well done, but it looks like you weren't one of those

> artistic kids who used to color the whole paper. It's

> cowardly to stay within the lines ;)

That just shows my timid and shy little character ;-)

kind regards,

Jos (don't look at me *blush*)

JosAHa at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 12
> > By 2 days> > OK - Wednesday 14:00 BST.sabre will sort you out. Wait for it...%
duffymoa at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 13

> > > By 2 days

> >

> > OK - Wednesday 14:00 BST.

>

> sabre will sort you out. Wait for it...

>

> %

I got a weird idea. What if the OP actually installed a JDK and tried to compile the code? Would that be possible? Nah

kajbja at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 14
> I got a weird idea. What if the OP actually installed> a JDK and tried to compile the code? Would that be> possible? NahYou're crazy! What kind of nonsense is this?!
RageMatrix36a at 2007-7-14 19:10:57 > top of Java-index,Java Essentials,New To Java...
# 15

> > I got a weird idea. What if the OP actually installed

> > a JDK and tried to compile the code? Would that be

> > possible? Nah

>

> You're crazy! What kind of nonsense is this?!

All those Scandinavians must be smoking extremely funny cigarettes.

kind regards,

Jos ("trying to compile code" *giggle* ;-)

JosAHa at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...
# 16

I've got the better idea for the OP: there are only seven distinct choices,

so there are only 7! ( == 5040) possible programs. Simply generate all

of them, save them to a temporary file (don't forget the ".java" extension)

and invoke javac on it. The first one that compiles cleanly is the

permutation of those seven choices that is correct.

kind regards,

Jos

ps. my 'rithmatic sucks big times ;-)

Message was edited by:

JosAH

JosAHa at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...
# 17

> I've got the better idea for the OP: there are only

> seven distinct choices,

> so there are only 7! ( == 5040) possible programs.

> Simply generate all

> of them, save them to a temporary file (don't forget

> the ".java" extension)

> and invoke javac on it. The first one that compiles

> cleanly is the

> permutation of those seven choices that is correct.

Why do it the hard way? The OP is actually posting all possible combinations :)

http://forum.java.sun.com/thread.jspa?threadID=757833&messageID=4328923#4328923

kajbja at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...
# 18

> Why do it the hard way? The OP is actually posting

> all possible combinations :)

You mean we have to go through 5038 more of these?

kind regards,

Jos ;-)

ps. it's 'permutations' here, not 'combinations' (*)

(*) some nasty little nitpicker wrote this, not me, oh no Sir.

JosAHa at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...
# 19
> ps. it's 'permutations' here, not 'combinations' (*)> > (*) some nasty little nitpicker wrote this, not me,> oh no Sir.Nah, it's all combinations for us who don't care about math :)
kajbja at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...
# 20
> I got a weird idea. What if the OP actually installed> a JDK and tried to compile the code? Would that be> possible? NahOr open a book?That's crazy talk.%
duffymoa at 2007-7-21 9:50:42 > top of Java-index,Java Essentials,New To Java...