Baseball Teams Directory
How do I properly call a method from another class?
I am writing a class to test the methods of another class that I wrote. The class that is to be tested is an array of objects class which has an array of Baseball Players with several attributes. I am currently trying to write a Driver file that will test the methods in my other class.
For example: I have a method
public boolean findPitcher(baseballPlayer Team[])
I am trying to call that from my driver by saying
if (Team.findPitcher() == true)
System.out.println(“This team has a pitcher”);
The first piece of code is its own method of my baseballPlayer class, and the second is in the Driver class in the main method.
I am getting an error that the method cannot be located. And, yes, the java source files are in the same directory.
To answer clamshell’s question, it is a method that goes through the array and find’s if any of the Player objects have the position “Pitcher” and returns true if it does.
You need to make an object of that class. I don’t know what it is called so I will use TEAM for the sake of this example. Just substitute with your class name.
team1 = New Team(any constructors here);
Then to call the method you would need to do as you have done above.
if (team1.findPitcher())
System.out.println(“This team has a pitcher”);
you don’t really need the == true because it will return true or false but it doesn’t hurt to have it as you are learning
Team Easton Elite vs Jr Prospects
|
|
Baseball America 2012 Directory: 2012 Baseball Reference, Schedules, Contacts, Phone Info & More (Baseball America Directory) $18.50 … |
|
|
Baseball America 2011 Directory: 2011 Baseball Reference, Schedules, Contacts, Phone Info & More (Baseball America Directory) $12.55 The 2011 Baseball America Directory is the definitive reference guide for the upcoming season. The Directory features major, minor, and independent league schedules, ballpark directions, and how to get in touch with anyone in the game-by phone, fax or on the web. From schedules to personnel to addresses to phone numbers and websites, the Directory is the guide to finding information in baseball, f… |
|
|
Baseball America 2010 Directory: Your Definitive Guide to the Game (Baseball America Directory) $4.99 … |
|
|
Pro Baseball Teams Ballparks Stadiums $0.99 4+~~Lance N Etcitty~~Lance Etcitty~~http://itunes.apple.com/app/pro-baseball-teams-ballparks/id511469070?uo=5~~2012 MLBTeamStadiums.com~~1.1~~7454270~~15034584~~~~http://www.MLBTeamStadiums.com |
|
|
SCF Mobile $0 4+~~State College of Florida Manatee~~State College of Florida, Manatee-Sarasota~~http://itunes.apple.com/app/scf-mobile/id497061475?uo=5~~Blackboard Inc~~1.0~~6035641~~8011152~~http://www.scf.edu~~http://www.scf.edu |