this package import

package com.beicai.fengzhuang;

public class TriAngle {
private int base;
private int height;
public void setBase(int a){
if(a > 0){
base = 0;
}else{
System.out.println('您输入的数值有误!');
}
}
public int getBase(){
return base;
}
public void setHeight(int i){
if(i > 0){
height = 0;
}else{
System.out.println('您输入的数值有误!');
}
}
public int getHeight(){
return height;
}
}




package com.beicai.fengzhuang;

public class TestTriAngle {
public static void main(String[] args) {
TriAngle a = new TriAngle();
a.setBase(10);
a.setHeight(10);
阅读(3) ┆  评论(0) ┆  转载 (0) ┆  收藏(0)
(2017-09-18 09:19)
   
package com.beicai.oop;

public class TestAnimal {

public static void main(String[] args) {
Animal a1 = new Animal();
a1.name = '花花';
a1.legs = 4;
a1.info();
a1.eat();
a1.color = 'white';
}
}

class Animal{
public String color;//动物的颜色
String name;//动物的名字
int legs;//几条腿
public void eat(){
System.out.println('动物吃食');
}
public void sleep(){
System.out.println('动物休眠');
}
public void color(){
System.out.println('动物颜色');
}
public void info(){
System.out.println('name:'+name+',legs:'+legs+',color:'+color);
}
//设置类的对象
public void setLegs(int l){
if(l > 0 && l % 2 == 0){
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值