The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with Inheritance Please :)

2 replies on 1 page. Most recent reply: Oct 23, 2002 9:59 AM by ben

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Natalie

Posts: 10
Nickname: natalie
Registered: Mar, 2002

Help with Inheritance Please :) Posted: Oct 20, 2002 12:45 PM
Reply to this message Reply
Advertisement
I am currently writing a program that simulates a coffee machine. The machine has three containers(milk,water,and coffee). There is therefore a Container class and a WaterTank class. The WaterTank class inherits from the Container class.

-Class Container contains the methods releaseContent(), amountLeft(), and resetVolumeContained().

The class looks like this with the constructor:

public class Container {

private int volumeContained;
private int minimumVolume;
Valve mainValve;
WarningLight mainLight;

public Container(int vContained, int minVolume)
{
volumeContained = vContained;
minimumVolume = minVolume;
mainValve = new Valve();
mainLight = new WarningLight();
}
and then the methods I mentioned above...

-Class WaterTank only contains one method called heatWater().

It probably sounds stupid, but how do I link them?


Ramzi Ben Yahia

Posts: 23
Nickname: miccheck
Registered: Jul, 2002

Re: Help with Inheritance Please :) Posted: Oct 21, 2002 12:55 AM
Reply to this message Reply
> I am currently writing a program that simulates a
> coffee machine. The machine has three
> containers(milk,water,and coffee). There is
> therefore a Container class and a WaterTank class.
> The WaterTank class inherits from the Container
> class.
>
> -Class Container contains the methods
> releaseContent(), amountLeft(), and
> resetVolumeContained().
>
> The class looks like this with the constructor:
>
> public class Container {
>
> private int volumeContained;
> private int minimumVolume;
> Valve mainValve;
> WarningLight mainLight;
>
> public Container(int vContained, int minVolume)
> {
> volumeContained = vContained;
> minimumVolume = minVolume;
> mainValve = new Valve();
> mainLight = new WarningLight();
> }
> and then the methods I mentioned above...
>
> -Class WaterTank only contains one method called
> heatWater().
>
> It probably sounds stupid, but how do I link them?

public class WaterTank extends Container
is that what you're really askihg or am I too dumb?

ben

Posts: 57
Nickname: loftty
Registered: Oct, 2002

Re: Help with Inheritance Please :) Posted: Oct 23, 2002 9:59 AM
Reply to this message Reply
hello

Flat View: This topic has 2 replies on 1 page
Topic: Sentence Counter Help,please :) Previous Topic   Next Topic Topic: help on program.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use