• Post Reply Bookmark Topic Watch Topic
  • New Topic

java beginner - assignment - constructor and different data types / confused  RSS feed

 
Arron Glickman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to java- writing a program for a university assignment. Any help / guidance would be appreciated.

I am passing a string through the constructor and assigning its value to a Grade type object class variable. I know its very simple but I cant figure out to make this work. I cannot modify the variables or the constructor arguments, only implement the constructor.

I looked through the methods from string but couldnt figure out after an hour what to do. casting/converting/ idk =(

 
Arron Glickman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guess i was just missing the creation of the object and using the new keyword to turn the string into the object - not sure why I didnt see that =\

gradeReceived = new Grade(grade);
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Well done sorting out that problem, but why are you using a String? Why not create an enumerated type for Grade?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!