This site requires JavaScript, please enable it in your browser!
Greenfoot back
SAMAD101
SAMAD101 wrote ...

2015/3/2

can someone tell me have i done something wrong

SAMAD101 SAMAD101

2015/3/2

#
mport greenfoot.*; /** * a world to demonstrate Ceasar Ciphering */ public class CipherWorld extends World { private Textbox textboxA, textboxB; // the text boxes private int codeKey; // the cipher key /** prepares world */ public CipherWorld() { super(380, 500, 1); addObject(textboxA = new Textbox(), getWidth()/2, 40); addObject(textboxB = new Textbox(), getWidth()/2, 80); } /** processes keyboard input and maintains string values of textboxes */ public void act() { String key = Greenfoot.getKey(); if (key != null) { if ("space".equals(key)) key = " "; if ("backspace".equals(key) && textboxA.getText().length() > 0) { String text = textboxA.getText(); text = text.substring(0, text.length()-1); textboxA.setText(text); } if ("escape".equals(key)) textboxA.setText(""); if ("up".equals(key)) codeKey = (codeKey+1)%26; if ("down".equals(key)) codeKey = (codeKey+25)%26; if (key.length() == 1) textboxA.setText(textboxA.getText()+key);
Moho Moho

2015/3/2

#
forgot the "i" infront of import in line number 1
SAMAD101 SAMAD101

2015/3/2

#
the part where it say key.length() == 1
danpost danpost

2015/3/2

#
Please do not start multiple discussion threads on the same issue. And please use 'code' tags for posting codes (refer to the 'Posting code? read this!' link below the reply box). Please refer to this discussion thread about this issue.
You need to login to post a reply.