Ai
1 Star 0 Fork 0

学C语言的枫子/Java_test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_04_28.java 988 Bytes
一键复制 编辑 原始数据 按行查看 历史
学C语言的枫子 提交于 2024-04-28 22:19 +08:00 . 日常
package test_01;
class Phone {
private String brand;
private double price;
public Phone() {
}
public Phone(String brand, double price){
this.brand=brand;
this.price=price;
}
public String getBrand()
{
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public double getPrice()
{
return price;
}
public void setPrice(double price) {
this.price = price;
}
public void call()
{
System.out.println("正在使用价格为"+price+"元的"+brand+"手机打电话");
}
public void listenMusic()
{
System.out.println("正在使用价格为"+price+"元的"+brand+"手机听歌");
}
}
public class test_04_28 {
public static void main(String[] args) {
Phone ph1=new Phone();
ph1.setBrand("华为");
ph1.setPrice(998);
ph1.call();
Phone ph2=new Phone("小米",998);
ph2.listenMusic();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/learning-c-language-feng/java_test.git
git@gitee.com:learning-c-language-feng/java_test.git
learning-c-language-feng
java_test
Java_test
master

搜索帮助