我该如何编写程序来做到这一点? [英] How can I write a program to do this?
问题描述
我正在尝试编写一个程序,以确定哪种狗适合一个人或一个家庭.我正在Mac上进行编程,我希望我的程序包括一种供人们检查有关其生活方式的陈述正确的框的方法,然后是一种搜索我制作的数据表并汇总其数量的方法.将人与每种狗的共同点分类,然后显示结果.我花了很多时间在Google搜索和尝试上,但是似乎没有任何工作对我有用.
I am trying to write a program that will determine what breed of dog is right for a person or family. I am programming on a Mac, and I want my program to include a way for people to check boxes of which statements are true about their lifestyles, and then a way to search a data table I''ve made and tally up the amount of categories the person has in common with each breed of dog, and then display the result. I''ve spent a lot of time googling things and trying things but nothing seems to work for me. Help?
推荐答案
我正在尝试编写一个程序,该程序将确定哪种狗适合一个人或一个家庭.
I am trying to write a program that will determine what breed of dog is right for a person or family.
现在,我在这一领域有丰富的经验.最近,我试图购买一只小狗,而宠物表演的主人则试图帮助我从我身上得到合适的那种小狗.他正在做什么,就像这样:
Now I have some great experience on this field. I recently tried to purchase a puppy and the pet show owner tried to help me to get the right kind of the puppy form me. What he was doing was something like this:
import java.util.Random;
public class FindYourDogType {
private static String[] dogTypes =
{
"Affenpinscher",
"Afghan Hound",
"Aidi",
//list goes on like this. List found at:
// http://en.wikipedia.org/wiki/List_of_dog_breeds
"Yorkshire Terrier"
};
private static Random random = new Random();
public static void main(String[] args) {
System.out.println("Your dog type is: " + getDogType());
}
private static String getDogType() {
return dogTypes[(random.nextInt() % dogTypes.length)];
}
}
这篇关于我该如何编写程序来做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!