Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
-- Theoretische Informatik (http://www.informatikerboard.de/board/board.php?boardid=5)
--- Zufallszahlen in Java vererbung Random (http://www.informatikerboard.de/board/thread.php?threadid=248)
Zitat: |
import java.util.*; public class RandomC extends Random{ private int u,o; private String zeichenkette2 = ""; public void RanomC(){ u = 32; o = 127; } public RandomC (int u , int o){ this.u = u; this.o = o; } public void setU(int u){ this.u=u; } public void setO(int o){ this.o=o; } public char nextChar(){ return (char)(nextInt(o-u)+u); } public String nextString(int n){ char [] zeichenkette = new char [n]; for (int i=0; i<zeichenkette.length ;i++){ zeichenkette[i] = nextChar(); zeichenkette2 = (zeichenkette2 + zeichenkette[i]); } return zeichenkette2; } } |
Zitat: |
public class App { public static void main (String args[]){ RandomC a = new RandomC(1,23); System.out.print(""+a.nextString(7)); } } |