小编Rya*_*dox的帖子

我怎么能比较java中的颜色?

我试图制作一个随机的颜色生成器,但我不希望类似的颜色显示在arrayList中

public class RandomColorGen {

public static Color RandColor() {
    Random rand = new Random();
    float r = rand.nextFloat();
    float g = rand.nextFloat();
    float b = rand.nextFloat();
    Color c = new Color(r, g, b, 1);
    return c;

}

public static ArrayList<Color> ColorList(int numOfColors) {
    ArrayList<Color> colorList = new ArrayList<Color>();
    for (int i = 0; i < numOfColors; i++) {
        Color c = RandColor();
        if(similarcolors){
            dont add
        }
        colorList.add(c);

    }
    return colorList;
}

}
Run Code Online (Sandbox Code Playgroud)

我很困惑请帮助:)

java random rgb colors

6
推荐指数
2
解决办法
1万
查看次数

使用chatterbean AIML interpeter制作alice bot

每当我尝试加载Alice aiml文件时,我会得到关于未找到的标签的各种错误,但是当我修复错误时,我得到一个错误,我不知道如何修复.目标事物没有被实现,但是我看看它正在强制它的目标类:我的代码:

public static String input()
{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    //System.out.println("you say>");
    String input = "";
    try 
    {
        input = in.readLine();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return input;
}




public static void main(String[] args) throws Exception
{
     Chat ch=new Chat();        
     AliceBotMother mother = new AliceBotMother();        
     mother.setUp();
     AliceBot bot = mother.newInstance();
     System.err.println(bot.respond("welcome"));
 while(true)
 {
     String input = Chat.input();
         // while the user saying 'bye'
         if(Chat.END.equalsIgnoreCase(input))
             break;
         // do some respond..
         System.err.println("Alice>" …
Run Code Online (Sandbox Code Playgroud)

java tags aiml

2
推荐指数
1
解决办法
4741
查看次数

标签 统计

java ×2

aiml ×1

colors ×1

random ×1

rgb ×1

tags ×1