编译此代码时出现同样的错误。我想知道如何成功添加出租天数和出租率。请帮忙。为什么我继续收到此错误“error:unexpected type”
Tractor.java:83: error: unexpected type
RentalDays + RentalRate = RentalProfit;
^
required: variable
found value
1 error
代码:
import java.util.*;
public class Tractor
{
private String name;
private int VehicleID;
private int RentalRate;
private int RentalDays;
public int setRentalRate(int RentalRate)
{
if (RentalRate <= 0 || RentalRate > 100000)
{
return -1;
}
else
{
return this.RentalRate;
}
}
public int getRentalRate()
{
return this.RentalRate;
}
public int setRentalDays(int RentalDays)
{
if (RentalDays <= 0 || RentalDays > 365)
{
return -1;
}
else
{
return this.RentalDays;
}
}
public int getRentalDays()
{
return this.RentalRate;
}
public int RentalProfit(int RentalRate, int RentalDays)
{
int RentalProfit;
RentalDays + RentalRate = RentalProfit;
}
}
谢谢sanky耆那教 – MajorJavaUser
这样做是为你工作。请接受我的回答 –