java叮当猫代码 叮当猫python代码

设计动物类Animal及其子类,将源代码保存至T3.java,具体要求如下:abstract class Animal{
String type;
public Animal(String type){
this.type=type;
}
public abstract void Talk();
public void showInfo(){Talk();}
}
class Dog extends Animal{
String name;
public Dog(String type,String name){
super(type);
this.name=name;
}
public void Talk(){
System.out.println("此动物是java叮当猫代码:"+name+"java叮当猫代码 , 此动物属于java叮当猫代码:"+type);
}
}
class Cat extends Animal{
String name;
public Cat(String type,String name){
super(type);
this.name=name;
}
public void Talk(){
System.out.println("此动物是java叮当猫代码:"+name+"java叮当猫代码,此动物属于:"+type);
}
}
public class Diy_5_2_1{
public static void main(String[] args){
Dog doggie=new Dog("犬科动物","德国黑贝");
Cat kitty=new Cat("猫科动物","波斯猫");
doggie.showInfo();
kitty.showInfo();
}
}
JAVA创建一个猫类Cat 。具体要求如下 急急急在线等public class Cat {
private static String hobby = "睡觉";
private String name;
private int weight;
private int age;
public Cat() {
this("", 0, 0);
}
public Cat(String name, int weight, int age) {
this.name = name;
this.weight = weight;
this.age = age;
}
public void climbTree(String name, int height) {
System.out.println(name + "会爬树,能爬" + height);
}
// 省略 getter // setter 方法.
@Override
public String toString() {
return "名字:" + this.name + "\r\n" + "体重:" + this.weight + "\r\n" + "年龄:" + this.age;
}
}
public class Main {
public static void main(String[] args) {
Cat catA = new Cat();
Cat catB = new Cat("兰兰", 8, 2);
catA.setName("花花");
catA.setWeight(10);
catA.setAge(3);
// 打印猫的信息
System.out.println(catA);
System.out.println(catB);
catA.climbTree(catA.getName(), -9999);
catB.climbTree(catB.getName(), 99999);
}
}
未测试
用java编程 定义一个Animal类 , 再定义它的两个子类Cat和Dog,并在Test类中创建Cat和Dog的对象 。急 急 急 !!import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Test {
public static void main(String[] args) {
Cat cat = new Cat();
Dog dog = new Dog();
cat.setColor("Yellow");
cat.setName("Kitty");
dog.setCry("Wang wang wang");
dog.setName("Wang Cai");
System.out.println("Cat's name: " + cat.getName());
System.out.println("Cat's color: " + cat.getColor());
System.out.println("Dog's name: " + dog.getName());
System.out.println("Dog's cry: " + dog.getCry());
}
}
class Animal{
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
class Cat extends Animal{
private String color;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
class Dog extends Animal{
private String cry;
public String getCry(){
return cry;
}
public void setCry(String cry) {
this.cry = cry;
}
}
-----------testing
Cat's name: Kitty
Cat's color: Yellow
Dog's name: Wang Cai
Dog's cry: Wang wang wang
Java宠物商店代码,求求各位大神帮忙//望采纳,打这么多字不容易
//用eclipse软件
一、问题描述
设计一个宠物商店,在商店中可以有多种宠物,试表示出此种关系,并要求可以根据关键字查找相应的宠物信息 。所需要的宠物信息自行设定 。

推荐阅读