newbie question zzzz

bun blame me 4 asking noob question >.<

Page 1 of 1

2 Replies - 485 Views - Last Post: 05 April 2009 - 10:33 AM Rate Topic: -----

#1 griever  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-April 09

newbie question zzzz

Post icon  Posted 05 April 2009 - 09:19 AM

sry, me noob here...i'm counting the total price of the table, the table made of teak, 2 meter length, 3 meter width, 4 drawer. i got the total of the price, but i dunno how make it alternatively to add the different price of the different wood.

price list

teak wood cost $300
oak wood cost $325
mahogany wood cost $350
pine wood cost 200$

drawer cost $50

surface area more than 2 square meters, add $50 for every extra meter

-------my-sad-separate's-line----------------------------------------------

public class OfficeTable {

public int length, width, drawer;
public double wood ;

public OfficeTable(int length, int width, int drawer, double wood)


{
this.length = length;
this.width = width;
this.drawer = drawer;
this.wood = wood;
}
public double getWood()
{

return wood ;
}

public double getMeter()
{
return ((length + width)-4) * 50 ;
}

public double getDrawer()
{
return drawer * 50 ;
}

public double calculatePrice()
{
return getWood() + getMeter() + getDrawer();
}
}


public class Table {

public static void main (String [] args){


OfficeTable Table = new OfficeTable(2, 3, 4, 300);

double total = Table.calculatePrice();

System.out.println(Table.calculatePrice());

}


}

Is This A Good Question/Topic? 0
  • +

Replies To: newbie question zzzz

#2 Mikeyp926  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 205
  • Joined: 20-March 09

Re: newbie question zzzz

Posted 05 April 2009 - 10:32 AM

1) please post within the code tags.

2) I'm not sure I understand your question. Does the assignment state somewhere what part of the desk is made of what type of wood? You construct the object based on dimensioned, but it seems that the price is based on type of wood. We really need some more info to help you out.

Can you give us any more information?

EDIT: Are you saying that each table is only made of one type of wood? In that case you could probably just find some way to multiply the dimensions by the price of the type of wood. ...although I'm still not sure I entirely understand your question.

-Michael

This post has been edited by Mikeyp926: 05 April 2009 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

#3 Sentrosi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 03-April 09

Re: newbie question zzzz

Posted 05 April 2009 - 10:33 AM

First, please put your code in code tags to make it easier to read. Second, I'm not entirely sure what you're asking, but it sounds like you want to use a scanner to get user input on how much the wood costs. Store their input in a variable, and send that to the constructor.

Sorry if that's not what you were asking.

Edit- Ha, got beat out by about a second =P

This post has been edited by Sentrosi: 05 April 2009 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1