• Post Reply 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

Help me!!!!! classes

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have to write a program that collect random caps with leters on them. one wins when all 5 caps r found. each cap has a ratio of being found. B-20% A-20% S-40% I-19% C-1%....i used a math.random and it had a range of 1-100 i assigned the first 20 to be B the next 20 to be A the next 40 to be C and so on. i need to write a class that recieves the numbers and assigns them to the letter. i am a bit confused on making classes. i made assignLetter class. i did if statements and a return statment and i keep getting this incompatiabel error with the return statement...dont know why. also how would u change and int to a char becuse i believe the letters are supposed to be converted to char not string(i did string) so if anyone could help i would greatly appreciate it

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sally,
The method:

says that it is going to return an object of type Bottles, but you are returning a String (letters.) That is why you are getting the compiler error.
To do characters, you use the char type and single quotes.
 
reply
    Bookmark Topic Watch Topic
  • New Topic