编写动物乐园java,满意会加分的!
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/07/30 14:39:18
编写动物乐园java,满意会加分的!
这是效果图,做到一半不会做了,很急!
做好了给加分哦!
拜托了!有的发一下,没有的帮忙做一下,谢谢!
到上面这就不会做了
![编写动物乐园java,满意会加分的!](/uploads/image/z/17226747-27-7.jpg?t=%E7%BC%96%E5%86%99%E5%8A%A8%E7%89%A9%E4%B9%90%E5%9B%ADjava%2C%E6%BB%A1%E6%84%8F%E4%BC%9A%E5%8A%A0%E5%88%86%E7%9A%84%21)
/>public class Animal
{
\x09public String name;
\x09public int legs;
\x09public String sound;
\x09public Animal(String name, int legs, String sound){
\x09\x09this.name = name;
\x09\x09this.legs = legs;
\x09\x09this.sound = sound;
\x09\x09
\x09}
\x09public String toString(){
\x09\x09return name + "\t" + legs + "\t" + sound;
\x09}
\x09public static void main(String[]args)
\x09{
\x09\x09//init
\x09\x09Animal[] animals = new Animal[3];
\x09\x09animals[0] = new Animal("加菲猫",4, "喵喵喵");
\x09\x09animals[1] = new Animal("唐小鸭",2, "嘎嘎嘎");
\x09\x09animals[2] = new Animal("海豚奇奇",0, "海豚音");
\x09\x09byte[] b = new byte[1024];
\x09\x09String[] names = {"猫", "鸭子", "海豚"};
\x09\x09int[] legs = {4,2,0};
\x09\x09String name;
\x09\x09int leg;
\x09\x09String sound;
\x09\x09while(true){
\x09\x09\x09try{
\x09\x09\x09\x09System.out.println("动物名称\t腿的条数\t动物叫");
\x09\x09\x09\x09for (int i = 0; i < animals.length; i++) {
\x09\x09\x09\x09\x09System.out.println(animals[i].toString());
\x09\x09\x09\x09}
\x09\x09\x09\x09System.out.println("0-修改,其他数字-退出");
\x09\x09\x09\x09int n = System.in.read(b);
\x09\x09\x09\x09String s = new String(b,0,n);
\x09\x09\x09\x09int oper = Integer.parseInt(s.trim());
\x09\x09\x09\x09if (oper != 0) {
\x09\x09\x09\x09\x09System.out.println("退出!");
\x09\x09\x09\x09\x09return;
\x09\x09\x09\x09}
\x09\x09\x09\x09for (int i = 0; i < animals.length; i++) {
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的名字");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09name = s.trim();
\x09\x09\x09\x09\x09if (name.length() == 0) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有名字");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的腿数");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09leg = Integer.parseInt(s.trim());
\x09\x09\x09\x09\x09if (leg != legs[i]) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有"+legs[i]+"条腿");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的叫声");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09sound = s.trim();
\x09\x09\x09\x09\x09if (sound.length() == 0) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有声音");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09animals[i].name = name;
\x09\x09\x09\x09\x09animals[i].legs = leg;
\x09\x09\x09\x09\x09animals[i].sound = sound;
\x09\x09\x09\x09}
\x09\x09\x09}
\x09\x09\x09catch(Exception e){
\x09\x09\x09\x09e.printStackTrace();
\x09\x09\x09}
\x09\x09}
\x09}
}凑合写的.
instanceof 不难吧...就是验证类是否为类或者父类的实例...我看你ppt要求的是自定义异常抛出,接口继承应该很简单,抛出异常参考我的代码即可..
再问: 麻烦你了。我是新手,能写的细点上传过来吗?我得慢慢研究。书上说动物类里是
还分了猫,鸭子,海豚三类![](http://img.wesiedu.com/upload/2/5f/25fb0a6576c7c379538b647417b7d122.jpg)
![](http://img.wesiedu.com/upload/e/ca/eca6cb3a5155a6ee475984526cb8e7a3.jpg)
还要定义一个接口
你能照这个模式做一个上传过来吗?拜托了,一定会加分的!!!
再答: 好,我明天弄吧,下班后坚决不碰代码
再问: 真是太感谢你了,麻烦你了!!!!!!!!!
再答: 代码粘不下了... 看附件吧
{
\x09public String name;
\x09public int legs;
\x09public String sound;
\x09public Animal(String name, int legs, String sound){
\x09\x09this.name = name;
\x09\x09this.legs = legs;
\x09\x09this.sound = sound;
\x09\x09
\x09}
\x09public String toString(){
\x09\x09return name + "\t" + legs + "\t" + sound;
\x09}
\x09public static void main(String[]args)
\x09{
\x09\x09//init
\x09\x09Animal[] animals = new Animal[3];
\x09\x09animals[0] = new Animal("加菲猫",4, "喵喵喵");
\x09\x09animals[1] = new Animal("唐小鸭",2, "嘎嘎嘎");
\x09\x09animals[2] = new Animal("海豚奇奇",0, "海豚音");
\x09\x09byte[] b = new byte[1024];
\x09\x09String[] names = {"猫", "鸭子", "海豚"};
\x09\x09int[] legs = {4,2,0};
\x09\x09String name;
\x09\x09int leg;
\x09\x09String sound;
\x09\x09while(true){
\x09\x09\x09try{
\x09\x09\x09\x09System.out.println("动物名称\t腿的条数\t动物叫");
\x09\x09\x09\x09for (int i = 0; i < animals.length; i++) {
\x09\x09\x09\x09\x09System.out.println(animals[i].toString());
\x09\x09\x09\x09}
\x09\x09\x09\x09System.out.println("0-修改,其他数字-退出");
\x09\x09\x09\x09int n = System.in.read(b);
\x09\x09\x09\x09String s = new String(b,0,n);
\x09\x09\x09\x09int oper = Integer.parseInt(s.trim());
\x09\x09\x09\x09if (oper != 0) {
\x09\x09\x09\x09\x09System.out.println("退出!");
\x09\x09\x09\x09\x09return;
\x09\x09\x09\x09}
\x09\x09\x09\x09for (int i = 0; i < animals.length; i++) {
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的名字");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09name = s.trim();
\x09\x09\x09\x09\x09if (name.length() == 0) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有名字");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的腿数");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09leg = Integer.parseInt(s.trim());
\x09\x09\x09\x09\x09if (leg != legs[i]) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有"+legs[i]+"条腿");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09
\x09\x09\x09\x09\x09System.out.println("请输入"+names[i]+"的叫声");
\x09\x09\x09\x09\x09n = System.in.read(b);
\x09\x09\x09\x09\x09s = new String(b,0,n);
\x09\x09\x09\x09\x09sound = s.trim();
\x09\x09\x09\x09\x09if (sound.length() == 0) {
\x09\x09\x09\x09\x09\x09throw new Exception(names[i]+"必须有声音");
\x09\x09\x09\x09\x09}
\x09\x09\x09\x09\x09animals[i].name = name;
\x09\x09\x09\x09\x09animals[i].legs = leg;
\x09\x09\x09\x09\x09animals[i].sound = sound;
\x09\x09\x09\x09}
\x09\x09\x09}
\x09\x09\x09catch(Exception e){
\x09\x09\x09\x09e.printStackTrace();
\x09\x09\x09}
\x09\x09}
\x09}
}凑合写的.
instanceof 不难吧...就是验证类是否为类或者父类的实例...我看你ppt要求的是自定义异常抛出,接口继承应该很简单,抛出异常参考我的代码即可..
再问: 麻烦你了。我是新手,能写的细点上传过来吗?我得慢慢研究。书上说动物类里是
![](http://img.wesiedu.com/upload/9/5a/95ab114740dbcfd8bdc9c27db5ee871e.jpg)
![](http://img.wesiedu.com/upload/2/5f/25fb0a6576c7c379538b647417b7d122.jpg)
![](http://img.wesiedu.com/upload/e/ca/eca6cb3a5155a6ee475984526cb8e7a3.jpg)
![](http://img.wesiedu.com/upload/2/95/2959287279e774c5161cfddde72d5889.jpg)
![](http://img.wesiedu.com/upload/b/5e/b5e76d01729930dbf40c0b0c7e8ff435.jpg)
再答: 好,我明天弄吧,下班后坚决不碰代码
再问: 真是太感谢你了,麻烦你了!!!!!!!!!
再答: 代码粘不下了... 看附件吧
会JAVA语言编写的帮下忙!
Java编写计算器的流程图
( )这个地方绿树成阴,( )会成为动物的乐园
铣床分度头的作用是什么?尽量详细些.如果回答的满意会相应加分的.
我爱国的作文写我是怎样爱国的,谢谢~~~~~~满意的我会加分
你认为狐假虎威中的狐狸怎么样,请评一评,我认为满意的会给你们加分
用JAVA编写求解几何图形的应用程序?
中文翻译成英文!翻译的满意我会直接给你加分的!不会的就别乱写了!
《法律基础》的相关问题、希望各位能帮忙解答、答案的理由能写也请帮我写下.满意会加分的
试说明晶体材料在凝固过程中细化晶粒的原理与方法.满意的会加分!
求各种子弹口径后面英文的意思还有有关军事的英文缩写答案满意我会加分
老舍 草原 原文快,好,准中文加英文,如果我满意的话还会加分的。希望快一些。