jeudi 5 mars 2015

Testing a class

I am trying to test the class by making a program. I don't really understand how to. All I know is that it has something to do with prime numbers, but that is all I know. Can someone please help me? I would really appreciate it if you do. Thank you.



import java.util.Scanner;
public class Android
{
public static int tag = 1;
private String name;
public static int n = 0;
Android ()
{
name = "Bob";
changeTag();
}

String getName(Object input)
{
return input.getClass().getName();
}

private static boolean isPrime(int n)
{
for(int i = n - 1; i > 0; i--)
{
if (n % i == 0)
{
return false;
}
}
return true;
}

public static void changeTag()
{
do
{
tag++;
} while (!isPrime(n));
}
}

Aucun commentaire:

Enregistrer un commentaire