I'm trying to write code that will let the user set their password length, and will output a random letter combination, which is the length the user specified.... Do i need to use a paralell array and greenfoot.getRandomNumber()? The code is listed below.. Thanks!
import greenfoot.*;
import java.awt.Color;
/**
* Write a description of class Generator here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Generator extends World
{
int i = 1;
String[] Letters =
{"1","2","3","4","5","6","7","8","9","0","A","a","B","b","C","c","D","d","E","e","F",
"f","G","g","H","h","I","i","J","j","K","k","L","l","M","m","N","n","O","o","P",
"p","Q","q","R","r","S","s","T","t","U","u","V","v","W","w","X","x","Y","y","Z","z",};
/**
* Constructor for objects of class Generator.
*
*/
public Generator()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
GreenfootImage background = getBackground();
background.setColor(Color.BLACK);
background.fill();
}
public void act()
{
int J = Integer.parseInt(Greenfoot.ask("How many letters would you like in your new password?"));
while (i < J)
{
showText(Letters[i], 300, 200);
i = i + 1;
showText("Click the 'Reset' button to reset Password Generator V 1.0", 300, 50);
Greenfoot.stop();
get
}
}
}
