Results 1 to 4 of 4
Thread: [SOLVED] Check command
- 04-02-2008, 01:40 AM #1
Member
- Join Date
- Mar 2008
- Posts
- 24
- Rep Power
- 0
[SOLVED] Check command
Hi, how code is needed to check an input of command so that, when the command is entered wrong it would return null;
example: on this class
Help would be greatPHP Code:public class Quit extends Commands { public Quit(Editor editor) { super("quit", editor); } public void execute() { System.out.println("Bye!"); System.exit(0); } }
Thanks
- 04-02-2008, 04:45 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If your command is a string, I think it is "Bye!", simply use a boolean variable, with comparing Strings. It the variable is true, do the process you want. If it is false do nothing.
- 04-02-2008, 04:53 AM #3
Azndaddy, what you're referring to is basic programming logic, fundamentally in the if/then area of logic. This will be a common task throughout your programming career and in this case, because the code you provided is a little obscure, is a task only you will be able to complete.
Post more general code and we can assist. But basically, it goes something like this:
Java Code:... if (command != desired) { // do something to imply wrong command } else { // do the thing you were meaning to do } ...Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-02-2008, 05:11 AM #4
Member
- Join Date
- Mar 2008
- Posts
- 24
- Rep Power
- 0
Similar Threads
-
CRC check program 1 error
By javakid9000 in forum New To JavaReplies: 1Last Post: 03-19-2008, 05:04 AM -
Can someone check my code
By joz_12345 in forum Java 2DReplies: 7Last Post: 02-18-2008, 02:58 AM -
spell check
By kazitula in forum Java AppletsReplies: 2Last Post: 12-20-2007, 11:37 AM -
check command method please
By dirtycash in forum New To JavaReplies: 1Last Post: 12-06-2007, 09:35 PM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks