| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| abstract class Product { |
| String name; |
| String date; |
| int sale; |
| int price; |
| |
| abstract void sell(); |
| |
| abstract void output(); |
| } |
| |
| class Mobile extends Product { |
| |
| void output() { |
| System.out.print(name + "," + price + "元 "); |
| } |
| |
| void sell() |
| { |
| System.out.println("销售的日期和时间:" + date+" " + "sales:" + sale + "¥"); |
| } |
| |
| |
| Mobile(String date, int price, String name, int sale) { |
| this.date = date; |
| this.price = price; |
| this.name = name; |
| this.sale = sale; |
| } |
| } |
| |
| class Pad extends Product { |
| |
| void output() { |
| System.out.print(name + "," + price + "元 "); |
| } |
| |
| void sell() |
| { |
| System.out.println("销售的日期和时间:" +date+" " + "sales:" + sale + "¥"); |
| } |
| |
| Pad(String date, int price, String name, int sale) { |
| this.date = date; |
| this.price = price; |
| this.name = name; |
| this.sale = sale; |
| } |
| |
| } |
| |
| public class Products { |
| |
| public static void main(String [] args) { |
| Mobile mobile1 = new Mobile("2019-09-14 22:03:41.054", 107780, "iphone 11 pro max",106800 ); |
| Mobile mobile2 = new Mobile("2019-09-14 22:03:41.054", 5450, "huaiwei p30", 6000); |
| Pad pad1 = new Pad("2019-09-14 22:03:41.054", 6999, "huaiwei pad", 7980); |
| Pad pad2 = new Pad("2019-09-14 22:03:41.054", 1380, "xiaomi pad", 1400); |
| Pad pad3 = new Pad("2019-09-14 22:03:41.054", 9500, "iphone pro", 9500); |
| Product[] products_ = {mobile1, mobile2, pad1, pad2, pad3}; |
| |
| for (int i = 0; i < 5; i++) { |
| products_[i].output(); |
| products_[i].sell(); |
| |
| } |
| |
| } |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-04-03 二叉查找树_删除节点
2021-04-03 datastructre_查找_顺序查找/折半查找(二分查找)/分块查找性能_二叉查找树_查找前驱节点