I`m Having some trouble with some extremely basic Java code for school. For the assignment we have to write code that will ask questions then spit the responses out. My variables are null and the stadium part runs into the year part. The are problems with the return part too.
Help would be appreciated. Thanks.
import static java.lang.System.out; import java.util.Scanner; class team{ private String sport; private String city; private String name; private String stadium; private String year; private String player; public void setsport (String sportIn) { out.print("What sport does the team play: "); sportIn = sport; } public void setcity (String cityIn) { out.print("What city does the team play in: "); cityIn = city; } public void setname (String nameIn) { out.print("What's your teams name: "); nameIn = name; } public void setstadium (String stadiumIn) { out.print("What's" + name + "Stadium"); stadiumIn = stadium; } public void setyear (String yearIn) { out.print("What year was" + name + "established: "); yearIn = year; } public void setplayer (String playerIn) { out.print("Who's" + name + "best player: "); playerIn = player; } private String info = (name + "play" + sport + "in" + city + "." + name + "were founded in" + year + "." + name + "best playert is" + player + "."); public String getinfo () { return info; } }
import java.util.Scanner; class assembly { public static void main (String args[]) { team a = new team(); Scanner scannera = new Scanner (System.in); a.setsport (scannera.next()); a.setcity (scannera.next()); a.setname (scannera.next()); a.setstadium(scannera.next()); a.setyear(scannera.next()); a.setplayer(scannera.next()); a.getinfo(); } }