定义一个 Room 类,包含成员变量面积和高度,以及内部类 Table 和 Chair , Table 和 Chair 皆包含成员变量长、宽、高以及颜色。现将一张长宽高分别为100cm,100cm,80cm的白色桌子以及一把长宽高分别为40cm,30cm,50cm的黑色椅子放进个面积为60平米,高度为4米的房间。编程打印房间、桌子、椅子的信息。
1条回答 默认 最新
- 不甘_ 2022-05-16 17:35关注
如有帮助望采纳
public class Room { static Double mianji=60d; static Double gaodu=4D; public static void main(String[] args) { Table table=new Table(); Chair chair=new Chair(); System.out.println(mianji); System.out.println(gaodu); System.out.println(table); System.out.println(chair); } private static class Table { String color="白色"; Double height=100D; Double weight=100D; Double length=80D; @Override public String toString() { return "Table{" + "color='" + color + '\'' + ", height=" + height + ", weight=" + weight + ", length=" + length + '}'; } } private static class Chair { String color="黑色"; Double height=50D; Double weight=30d; Double length=40D; @Override public String toString() { return "Chair{" + "color='" + color + '\'' + ", height=" + height + ", weight=" + weight + ", length=" + length + '}'; } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 3无用
悬赏问题
- ¥15 keil的map文件中Image component sizes各项意思
- ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
- ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
- ¥15 划分vlan后,链路不通了?
- ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
- ¥15 Vue3 大型图片数据拖动排序
- ¥15 Centos / PETGEM
- ¥15 划分vlan后不通了
- ¥20 用雷电模拟器安装百达屋apk一直闪退
- ¥15 算能科技20240506咨询(拒绝大模型回答)