I need help with aggregation class

Joined
Dec 4, 2008
Messages
1
Reaction score
0
I wrote this code and its telling me that i cannot perform the * operation in my totalCost method, can someone tell me whats wrong and how can i fix it plz? ty.

public class RoomCarpet
{
private RoomDimension room;
private double cost;

public RoomCarpet()
{
room = new RoomDimension();
cost = 0;
}
public RoomCarpet(double length, double width, double c)
{
room = new RoomDimension(length, width);
cost = c;
}
public void setCost(double c)
{
cost = c;
}
public double getCost()
{
return cost;
}
public double totalCost()
{
return room * cost; //this is where i get the error message
}
public String toString()
{
String str;
str = room.toString() + "\n" + "The cost of the square foot of carpet is "
+ getCost() + "\n" + "The total cost of carpet is" + totalCost();
return str;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top