Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: simple IF question if (newplayer == goalkeeper) {throw
zcraven wrote:
> if (p2,p3,p4==Goalkeeper)
>         {
>             throw new IllegalArgumentException("You cannot put a goalkeepe
r
> in an   outfield position");
>         }
>
>
> I want to check that the variables p2 to p11 are of class OutfieldPlayer a
nd
> not Goalkeeper (Both OutfieldPlayer and Goalkeeper are subtypes of abstrac
t
> class Player).  How do I write an if to check that the variables are of a
> certain class?

You should probably have a moveTo() method in Player
and override it as appropriate so
newplayer.moveTo(OUTFIELD)
would throw an exception if newplayer is an instance of Goalkeeper.

Report this thread to moderator Post Follow-up to this message
Old Post
Thomas Schodt
10-28-04 01:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:21 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.