Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me!!!!! classes  RSS feed

 
Sally Curtis
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37242
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!