Java: missing return staement error? (Probably easy fix...)

MysticalGoat :

Please look at attached pictures.

The main purpose of SelectCharacter.
- General 3 in-game "characters" and lets the user select one by 1,2 or 3
- return the selected character (Archer, Ninja, Warrior)
- This will then be instantiated in the Main class

Getting following error: Error:(32, 5) java: missing return statement

I've tried case statements and not too sure what the issue is now.
Any Advise is appreciated
if I've missed something please let me know and I can provide more if required :)

SelectCharacter Class

Main Class

Aditya Rewari :

You are not handling condition, when input != [1,2,3], say input =4.

Either make the last else-if in ChooseCharacter() as else only

OR

Add a return statement after your if - else if - else if ,returning a Person Object

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=31691&siteId=1