//定义一个手机类
class Cellphone
{
//品牌
String brand;
//年龄
int price;
//性别
String color;
//定义行为方法打电话
public void call(){
System.out.print("打电话!");
}
//定义发信息方法
public void sendMessage(){
System.out.print("发信息!");
}
//玩游戏
public void playGame(){
System.out.print("玩游戏!");
}
}
class StudentDemo
{
public static void main(String[] args){
Cellphone zi =new Cellphone();
zi.brand="苹果6s";
zi.price=998;
zi.color="土豪金";
System.out.println("这是一款"+zi.brand+"颜色"+zi.color+"价格只要"+zi.price+"哦");
System.out.print("而且还具备");
zi.call();
zi.sendMessage();
zi.playGame();
System.out.print("等功能,快点抢购吧 !!!");
}
}
|
|