編譯此代碼時出現同樣的錯誤。我想知道如何成功添加出租天數和出租率。請幫忙。爲什麼我繼續收到此錯誤「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
這樣做是爲你工作。請接受我的回答 –