Bookmark Topic Watch Topic
  • New Topic

Methods  RSS feed

 
Ken Terp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello all,

I need a little help at this point as I am completely stumped at this point on how to get this method to work. Any direction would be much appreciated. I have to create a method that takes in one parameter as input as a value char which is easy enough ...

public static char getCharType(char promoType){

The part that I can't seem to grasp is this. Based on that input of char type I have to match it up to a string and return a string. How can I convert a char to a string? I know there is probably a simple answer but it has eluded me for about 12 hours now and the laptop is about to go out the window. Any help or direction would be greatly appreciated.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm confused about your question. The return type on that method is char, not String. Are you just trying to create a String that contains your character, or are you trying to return a String that is associated in a certain way with your character?
 
Ken Terp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, thanks for the reply.

I'm trying to return a String that is associated with a character.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Report post to moderator
But the return type of the method is char.
 
Ken Terp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Report post to moderator
I guess that's why I am so confused. Here's are the instructions exactly as they were given to me.

Write the getCharType method.

Place the method defination code below the main method of the existing program class.

Include the modifier static in the method header.

The getCharType method must:
Take one parameter as input: the promo type as a value of type char.
Determine the full name of the promo type, ie Free shipping, Coupon, Special promo or None.
Return the full name of the promo type as a string.

Thats the instruction I was given. Can it be done? Because I've been trying for about 14 hours now and can't find a way.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by Ken Terp:
I guess that's why I am so confused. Here's are the instructions exactly as they were given to me.

Write the getCharType method.

Place the method defination code below the main method of the existing program class.

Include the modifier static in the method header.


Okay, they want you to declare a new static method named "getCharType" below the apparently existing main method. Do you know how to do that?

Originally posted by Ken Terp:
The getCharType method must:
Take one parameter as input: the promo type as a value of type char.
Determine the full name of the promo type, ie Free shipping, Coupon, Special promo or None.
Return the full name of the promo type as a string.

Thats the instruction I was given. Can it be done? Because I've been trying for about 14 hours now and can't find a way.


So you need one parameter that is a char and you must return a String. Do you know how to declare a method returns a String and accepts one char as a parameter?

Once you do that worry about how to make the actual conversion.
 
Ken Terp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks I think I understand now.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
This thread seems to be continued here, so I'm closing this one.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!