Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Methods

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
But the return type of the method is char.
 
Ken Terp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks I think I understand now.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This thread seems to be continued here, so I'm closing this one.
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic