gpt4 book ai didi

java - 如何定义属性?

转载 作者:行者123 更新时间:2023-12-01 15:07:02 26 4
gpt4 key购买 nike

下面的问题让我很困惑,我不确定我的想法是否正确。这就是问题

Given three straight lines a, b & c. They will be able to form a triangle provided that sum of any two lines is always greater than the third line (i.e. a + b > c and b + c > a and a + c

b). Write a Java class Triangle with the following:

Attributes: length of the three sides of the triangle 
Behaviour:
  • Constructor that sets the length of the three sides to the values passed in. The constructor should throw an InvalidValueException object when the values are not able to form a triangle.
    • findArea() method to calculate the area of the Triangle object using the formula area = a +b+c

请注意,问题的下一部分是创建 GUI。我已经这么做了。

所以上面的问题是要求我简单地获取值,但是从哪里获取?是通过GUI吗?或命令行基础?问题并不具体,所以我可以假设简单地创建准备接受值的变量吗?

最佳答案

如果你被要求开发一个 GUI,我真的认为必须通过它输入值......并且 Triangle 类必须有 3 个属性:a、b 和 c。

关于java - 如何定义属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12835537/

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