

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


O-O solution
private String name; private int won; private int lost; public String () { return name; } public int getWon () {return won; } public int getLost () {return lost; } public void setName(String n) { name = n; } public void setWon (int w) {won = w; } public void setLost (int l) {lost = l; } Public int stats() {return 100 * won / (won + lost); } } Public class soccer { Public static void main (String [] args) { Team myTeam = newTeam ( ); Team another = newTeam ( ); teamName = JOptionPane.ShowInputDialog(“Name:”)
another.setName(JOptionsPane.ShowInputDialog(“Name:”)); . Mistake!: public void setName(String name) {name = name; }
- Problem is one variable is **representing for two things