Results 1 to 4 of 4
Thread: Super simple question
- 01-26-2009, 12:43 AM #1
Senior Member
- Join Date
- Nov 2008
- Posts
- 105
- Rep Power
- 0
Super simple question
Hello, I am just confused by the wording of the question.
e) The OilTank class, below, includes six methods. Which ones can be used to change the state of an OilTank object?
So I just saidJava Code:public class OilTank{ private int capacity; // capacity of tank private String who; // tank owner private double price; // price per gallon of oil private int quantity; // gallons of oil in tank public OilTank(String who, int cap, double price, int quant){ this.who = who; capacity = cap; this.price = price; quantity = quant; } public int getCapacity(){return capacity;} public String getWho(){return who;} public double getPrice(){return price;} public int getQuantity(){return quantity;} public void setQuantity(int amt){ quantity = amt;} public void fillTank(){quantity = capacity; } }
public void setQuantity(int amt){ quantity = amt;}
public void fillTank(){quantity = capacity; }
public OilTank(String who, int cap, double price, int quant){
this.who = who;
capacity = cap;
this.price = price;
quantity = quant;
}
Is that what this is asking? Just want to make sure I am doing the right thing.
-
The state of an object is defined by it's fields -- what values do they hold? A method will change an object's state if it changes any one of these fields. So on quick glance, I think you have it right. Nice job.
edit: you are including the constructor in your list which isn't a method. I'd remove that.
- 01-26-2009, 01:05 AM #3
dam fujaninja you are fast, i was just about to ans.
i agree, but the question ask for the six methods.
--"he OilTank class includes six methods."--
so i don't think the constructor counts, right?USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 01-26-2009, 01:17 AM #4
Senior Member
- Join Date
- Nov 2008
- Posts
- 105
- Rep Power
- 0
Similar Threads
-
Simple question about access
By tortelini in forum New To JavaReplies: 6Last Post: 09-06-2008, 05:41 PM -
Simple Method Question
By Froz3n777 in forum New To JavaReplies: 2Last Post: 02-13-2008, 02:39 AM -
Simple append question
By Rageagainst20 in forum New To JavaReplies: 0Last Post: 12-20-2007, 11:40 PM -
Probably a really simple question...
By ibanez270dx in forum New To JavaReplies: 0Last Post: 11-16-2007, 01:27 AM -
Simple question of JTable
By carl in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 07:07 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks