首页 > 编程知识 正文

前端模拟数据,将查询对象改为参数查询

时间:2023-05-05 02:57:13 阅读:59810 作者:3363

任务1 :创建显示手机配置和功能的程序

)1)定义一个手机类Phone。

)2)手机具有品牌(brand )、型号(type )、价格(price )、操作系统)、内存(memory )的属性。 因此,需要在手机类中定义品牌(brand )、型号()、价格)、操作系统()、内存)、内存(memory )的变量。

)3)手机有手机信息(about )、打电话(call(stringno )、玩游戏(playGame ) )、下载音乐(downloadMusic )、音乐

)4)制作了两个手机对象,输出了这两个手机对象的属性和功能。

任务1代码如下:

打包测试1; 公共类别手机{私有用户品牌; 私有内类型; 隐私保密; 隐私字符串操作系统; 私有字符串内存; publicstringgetbrand ((返回品牌; } publicvoidsetbrand (字符串brand ) {this.brand=brand; }public int getType () {return type; }公共语音设置类型(inttype ) {this.type=type; }public int getprice () {return price; }publicvoidsetprice(intprice ) {this.price=price; }public String getOs () {return os; }publicvoidsetos(stringOS ) {this.os=os; }公共字符串获取内存() {return memory; } publicvoidsetmemory (字符串内存) {this.memory=memory; }public Phone () publicphone(stringbrand,int type,int price,String os,String memory ) {this.brand=brand; this.type=type; this.price=price; this.os=os; this.memory=memory; }public String about () {return手机品牌为(this.brand ),手机型号为) this.type; }publicstringcall(stringno ) {return )使用' this.brand '手机' no; }public String playGame (() {return '' this.brand '用手机玩游戏); }public String downloadMusic () {return '' this.brand '用手机下载音乐); }public String playMusic (() return('this.brand )用手机放音乐); } }打包测试1; public class main { publicstaticvoidmain (字符串[ ] args ) ) {Phone phone1=new Phone; phone1.setbrand('vivo ' ); phone1.settype(1; Phone1.setprice(2000; phone1.setos(windows ); phone1.setmemory('128g ); system.out.println (phone1. about ); system.out.println (phone1. call (' 123456 ) ); system.out.println (phone1. play game (); 系统. out.println (phone1. download music (); system.out.println (phone1. play music (); system.out.println (---------------' ); Phone phone2=new Phone (; phone2.setbrand('oppo ); phone2.settype(2; Phone2.setprice(2300; phone2.setos('Linux ' ); phone2.setmemory('248g ); system.out.println (phone2. about ); system.out.println (phone2. call (' 24689 ) ); system.out.println (phone2. play game (); 系统. out.println (phone2. download music () ); system.out.println (phone2. play music (); }运行结果如下。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。