Lab 2009 #03

Lab_20091126.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class Lab_20091126
{
	public void print(String a)
	{
		System.out.print(a);
	}
 
	public static String scelta(String[] s)
	{
		int indice = (int) Math.round( Math.random() * (s.length - 1) );
		return s[indice];
	}
 
	public static void main(String[] argv)
	{
		String[] vocabolario = {
			"java",
			"programmazione",
			"oggetti"
		};
 
		String parola = scelta(vocabolario);
 
		char[] trattini = new char[parola.length()];
 
		for (int i=0; i<trattini.length; i++)
		{
			trattini[i] = '_';
			print(""+trattini[i]);
		}
	}
}

About the Author

Hello everyone! I'm Andrea Rastelli, a 23 year old programmer, designer, 3D animator and compositor. You may follow me on Twitter and Facebook