gpt4 book ai didi

java - 如何将一个构造函数的值设置为另一个构造函数的值?

转载 作者:搜寻专家 更新时间:2023-11-01 03:01:56 24 4
gpt4 key购买 nike

<分区>

我目前正在我的大学学习初级 Java 类(class),并且仍在学习编程的基础知识。本周我们一直在学习构造函数,我被困在本周作业的后半部分,因此非常感谢任何帮助。

实验第二部分(我卡住的部分)的说明如下:

Write the complete code for the class Truck as given in the class diagram below. Be sure to not use duplicate code in the constructors. For example, the constructors with 2 arguments should call the one with 1 argument to set the value for cylinder.

这些是它要我制作的构造函数。

  • 卡车()
  • 卡车(int cylinders)
  • Truck(int cylinders, String manufacturer)
  • Truck(int cylinders, String manufacturer, double load)
  • Truck(int cylinders, String manufacturer, double load,
    双拖)

任何关于如何做到这一点的解释/例子都会很棒

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com