Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-01-2007, 12:16 AM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Need Help Please
Hi, i'm currently trying to make a simplish program for calculating soccer results. I'm having trouble with one of my subclasses. The tester class cannot find the methods. Any advice would be appreciated

Thanks

Last edited by Renegade85 : 12-04-2007 at 10:11 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-01-2007, 02:31 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
public static void main(String[] args) { Score t1 = new Score("Arsenal", 90); Score t2 = new Score("Aston Villa", 78); t1.calculateScore(t1, t2); System.out.println(t1.getTeamName() + " " + t1.getHomeScore() + "-" + t1.getAwayScore() + " " + t2.getTeamName()); }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-01-2007, 06:36 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Thanks hardwired

I'm having another problem now though. Basically i want to have a class that runs when the user program is opened and loads an arraylist with values. Can you do that or will i have to just do it in the main program?

Last edited by Renegade85 : 12-04-2007 at 10:21 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-01-2007, 08:53 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
public class TeamLoader { public static void main(String[] args) { String[] names = { "Arsenal", "Aston Villa", "Birmingham", "Blackburn", "Bolton", "Chelsea", "Derby", "Everton", "Fulham", "Liverpool", "Man City", "Man Utd", "Middlesbrough", "Newcastle", "Portsmouth", "Reading", "Sunderland", "Tottenham", "West Ham", "Wigan" }; int[] ratings = { 90, 78, 65, 81, 60, 91, 50, 74, 76, 90, 89, 91, 82, 77, 83, 59, 57, 81, 74, 54 }; TeamInfo[] teams = new TeamInfo[names.length]; for(int j = 0; j < teams.length; j++) { teams[j] = new TeamInfo(names[j], ratings[j]); } Team team = new Team("a team", 100); team.addTeams(teams); System.out.println(team); System.out.println("bestRated = " + team.getBestRatedTeam()); } } class Team extends TeamInfo { ... public void addTeams(TeamInfo[] newTeams) { for(int j = 0; j < newTeams.length; j++) teams.add(newTeams[j]); }
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-01-2007, 09:48 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Thanks again hardwired

Just one more thing i need to get working and that'll be the program done.

I can't get one of my cases to work. Will let ya's know how i get on

Last edited by Renegade85 : 12-04-2007 at 10:15 PM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-01-2007, 10:18 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Got it going. Just a few minor errors i need to get sorted now

Last edited by Renegade85 : 12-04-2007 at 10:16 PM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-02-2007, 12:14 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
I can't get case 1 to work. All the other classes are the same as in my above post except i added the addTeams() method to Team
The Score class you posted above has some problems.
Code:
// Methods like this protected int setAwayScore() { return score2; } // should be implemented like this protected void setAwayScore(int score) { score2 = score; }
As for your last–posted UserProgram class, compiling gives this in the console:
Code:
C:\jexp>javac scoretesterrx.java scoretesterrx.java:55: getRating() in TeamInfo cannot be applied to (java.lang.S tring) tempRating=team1.getRating(teamName); ^ scoretesterrx.java:61: getRating() in TeamInfo cannot be applied to (java.lang.S tring) tempRating=team2.getRating(teamName); ^ 2 errors
Score extends TeamInfo and inherits the getRating method from this superclass.
The TeamInfo getRating method (from post #3) is:
Code:
public int getRating() { return rating; }
So you are calling a method that does not exist.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 12-02-2007, 12:36 AM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Ok thanks for pointing them out hardwired. I have to go to work now so will try fix them tomorrow morning. I'll let you know how i get on
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 12-02-2007, 06:36 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Got most of it sorted now. A few more minor errors and i'm done

Last edited by Renegade85 : 12-04-2007 at 10:17 PM.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 12-02-2007, 07:53 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Got it all running now. Thanks for all your help hardwired

Last edited by Renegade85 : 12-02-2007 at 10:36 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 04:40 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org