- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我确信这是一个菜鸟问题,但在我正在处理的程序中,我试图传递一个变量作为参数,这很容易,但我被困住了,因为我的变量尝试通过是之前两个参数的产物。
我必须为机动车辆创建一个对象,其中包含车主姓名、车轮数量和排量(升)参数,但第四个也是最后一个参数是排量与数量相乘的结果车轮组合在一起,称为“马力”(尽管我很确定这不是马力的真正计算方式。)
无论如何,在定义“MotorizedVehicle”的类中,我有以下代码。
/*
public class MotorizedVehicle extends Bicycle {
int litersDisplaced;
int horsepower = litersDisplaced * wheelCount;
public MotorizedVehicle(String ownerName, int wheelCount, int litersDisplaced, int horsepower){
this.ownerName = ownerName;
this.wheelCount = wheelCount;
this.litersDisplaced = litersDisplaced;
this.horsepower = horsepower;
}
public int getLitersDisplaced() {
return litersDisplaced;
}
public void setLitersDisplaced(int litersDisplaced) {
this.litersDisplaced = litersDisplaced;
}
public int getHorsepower() {
return horsepower;
}
public void setHorsepower(int horsepower) {
this.horsepower = horsepower;
}
}
现在,在客户端类中我有以下代码:
/*
package extracredit4;
/**
*
* @author ChetSpalsky
*/
public class VehicleClient {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
MotorizedVehicle car1 = new MotorizedVehicle("Bill", 2, 4, *); //Where I have the * this is where the argument for the "horsepower" variable or method should be, but I don't know what to put here to call the variable that will be litersDisplaced * wheelCount.
}
}
需要明确的是,我不能只将“8”放在第四个参数应该所在的位置,我必须调用将literDisplaced 和wheelCount 相乘的方法。
很抱歉,如果这是一个会让经验丰富的程序员捂脸的问题,但我已经查遍了,似乎找不到这个问题的答案,我真的很感谢你的帮助。谢谢!
最佳答案
只需输入 2 * 4,如 MotorizedVehicle car1 = new MotorizedVehicle("Bill", 2, 4, 2 * 4);
关于Java如何使参数成为另外两个参数的乘积?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36950622/
我希望我的问题有一个非常简单的解决方案。我只是找不到它: 假设您有两个向量(一个是列向量,一个是行向量)A、B: A = [1,2,3] B = [4;5;6] 如果我们按如下方式将它们相乘,我们会得
我有一个 Tuple 的列表: "dog", 25 "cat", 5 "cat", 7 "rat", 4 "dog", 10 我需要的 Linq 查询规则必须满足以下条件:我需要按字符串值对元组进行分
给定 2 个不同的 NDarray,A 和 B,形状相同但尺寸任意,我如何获得 NDarray C,其中 C 是 A 和 B(含)范围内所有整数的乘积。 我的意思是A是起始数组,B是结束数组,我想要数
假设我需要为某些输入构建一个真值表,它要求我提供逻辑和、算术和和逻辑乘积。它们之间有什么区别? 最佳答案 逻辑和 - 一种计算机加法,当一个或两个输入变量为 1 时,结果为 1;当输入变量均为 0 时
我正在尝试执行一个简单的矩阵乘法 vector 乘法,但出于某种原因,我在几次乘法的结果中得到了错误的符号。我不知道为什么会这样,任何指针将不胜感激。 这是我的全部代码,即矩阵 * vector 函数
我在上一个主题中找到了一些关于 cuda 矩阵 vector 积的代码: Matrix-vector multiplication in CUDA: benchmarking & performanc
我遇到的第一个问题是显示三个数字中的最小和最大。出现两个单独的警报 - 第一个警报说第二大数字是最大的(因为它还没有考虑第三个数字),第二个警报正确地指出三个中最大的数字是最大的.不确定为什么会这样—
我有两个矩阵 a = np.matrix([[1,2], [3,4]]) b = np.matrix([[5,6], [7,8]]) 我想得到元素乘积,[[1*5,2*6], [3*7,4*8]],等
我有一个数组和一个 vector : ArrayXd m1(3, 1337); ArrayXd v1(1, 1337); ArrayXd result(3, 1337); 现在我想将 m1 的每一行与
我有两个 3D 矩阵: a = np.random.normal(size=[3,2,5]) b = np.random.normal(size=[5,2,3]) 我想要每个切片分别沿 2 轴和 0
我正在创建一个 C++ 软件,我需要一个包装器,它基于 Eigen 库,实现类似于官方网页中解释的运算符* https://eigen.tuxfamily.org/dox/group__Matrixf
我正在尝试将张量 (m, n, o) 分解为矩阵 A(m, r)、B (n, r) 和 C (k, r)。这被称为 PARAFAC 分解。 Tensorly已经做了这种分解。 一个重要的步骤是将 A、
我目前正面临这个问题。我有两个矩阵 MatrixXf答: 0.5 0.5 0.5 0.50.694496 0.548501 0.680067 0.7171110
我有以下 df: df = pd.DataFrame({'A': ['foo', 'bar', 'dex', 'tru'], 'B': ['abc', 'def'
假设我们有 2 个 2X2 numpy 数组: X=np.array([[0,1],[1,0]]) 和 I=np.array([[1,0],[0,1]]) 考虑一下克罗内克产品 XX=X^X 我让符号
我想弄清楚这是 Eigen 中的错误还是我做错了什么。我只想要两个复数 vector [1,i] 和 [1,-i] 的点积。答案是 1*1 + i*(-i) = 2。但是 Eigen 给出的答案是零。
我的 C 代码有问题。我所做的就是这样: #include int main() { float zahlen[2]; for (int i = 0; i < 2; i++) {
为了找到数字的因数,我正在使用函数 void primeFactors(int n) # include # include # include # include using namespa
我是一名优秀的程序员,十分优秀!