应该与OOP的概念有关,JAVA是老外教的,听不太懂。甚至都没什么基础哈哈
2条回答 默认 最新
- Disaster_Star 2021-11-02 21:00关注
public class McmLength {
private int m;
private int cm;
private int hm;public McmLength() { } public McmLength(int hm) { this.hm = hm; } public McmLength(double cm) { this.cm = (int) cm; } public McmLength(int m, int cm, int hm) { this.m = m; this.cm = cm; this.hm = hm; } public int add(int x, int y) { return x + y; } public int sub(int x, int y) { return x - y; } public double z(int x, int y) { return x / y; } public int s(int x, int y) { return x * y; } public int Max(int x, int y) { return Math.max(x, y); } public static void main(String[] args) { McmLength M1 = new McmLength(); McmLength M2 = new McmLength(2); McmLength M3 = new McmLength(2.3); McmLength M4 = new McmLength(1, 2, 3); System.out.println(M1); System.out.println(M2); System.out.println(M3); System.out.println(M4.add(1, 2)); System.out.println(M4.sub(3, 4)); System.out.println(M4.z(5, 6)); System.out.println(M4.s(7, 8)); System.out.println(M4.Max(9, 0)); }
}
你这题目都是翻译过来的吧?本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 mysql sum函数优化
- ¥15 求高通平台Softsim调试经验
- ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
- ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
- ¥15 栅极驱动低侧烧毁MOSFET
- ¥30 写segy数据时出错3
- ¥100 linux下qt运行QCefView demo报错
- ¥50 F1C100S下的红外解码IR_RX驱动问题
- ¥20 基于matlab的航迹融合 航迹关联 航迹插补
- ¥15 用Matlab实现图中的光线追迹