The Artima Developer Community
Sponsored Link

Java Answers Forum
Getting values from an array.........

0 replies on 1 page.

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 0 replies on 1 page
Jimbob

Posts: 3
Nickname: kingpin
Registered: Nov, 2002

Getting values from an array......... Posted: Dec 1, 2002 7:25 AM
Reply to this message Reply
Advertisement
OK I have an array where coffee values are given:

styles = new CoffeeStyle[3];
styles[0] = new CoffeeStyle("Dark Coffee", 30,0,100);
styles[1] = new CoffeeStyle("White Coffee", 20,40,100);
styles[2] = new CoffeeStyle("Extra Strong Coffee", 40,20,100);


The user chooses a style from an Interface drop down comboBox. The value is stored in an String object called coffeeType. This is where I want to test the value in the String coffeeType with the values above to see which choice is made:


if (coffeeType != null && coffeeType.equals(styles[0].name)) {
then return values();
}
if (coffeeType != null && coffeeType.equals(styles[1].name)) {
then return values();
}
if (coffeeType != null && coffeeType.equals(styles[1].name)) {
then return values();


The values are coffee, milk and water which I need to deduct from a class called Container:


public class Container {

private int volumeContainedCoffee;
private int volumeContainedWater;
private int volumeContainedMilk;

private int minimumVolumeCoffee;
private int minimumVolumeWater;
private int minimumVolumeMilk;

Valve mainValve;
WarningLight mainLight;


public Container(int vContainedCoffee, int vContainedWater, int vContainedMilk, int minVolumeCoffee, int minVolumeWater, int minVolumeMilk)
{
volumeContainedCoffee = vContainedCoffee(500);
minimumVolumeCoffee = minVolumeCoffee(20);

volumeContainedWater = vContainedWater(2000);
minimumVolumeWater = minVolumeWater(500);

volumeContainedMilk = vContainedMilk(500);
minimumVolumeMilk = minVolumeMilk(20);

mainValve = new Valve();
mainLight = new WarningLight();
}

Public releaseContent()
{



}
Public amountLeft()
{
if (volumeContainedCoffee == minimumVolumeCoffee)
then textArea.setText ("Running Low On Coffee Powder!");


How would I go about deducting the values in the array from the values in the three containers?

Topic: I want to create a game, BUT HOW? Previous Topic   Next Topic Topic: Rs232 - Java comm api

Sponsored Links



Google
  Web Artima.com   

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