-
-
Save lithid/6382758 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Main.java | |
import javax.swing.JOptionPane; | |
public class Main { | |
public static void main(String[] args){ | |
String s; | |
Secondary f; | |
f = new Secondary(); | |
f.food(); | |
s = JOptionPane.showInputDialog("Enter fruit desire: "); | |
f.desire = Double.parseDouble(s); | |
f.factor = f.desire / f.fruit; | |
for (int i=0; i<f.mFruitList.length; i++) { | |
f.mFruitList[i] = f.factor * f.mFruitList[i]; | |
System.out.println(f.mFruitName[i]": " + f.mFruitList[i]); | |
} | |
} | |
} | |
//Secondary.java | |
public class Secondary { | |
public static final APPLE = 0; | |
public static final BANANA = 1; | |
public static final ORANGE = 2; | |
public double fruit, desire, factor; | |
public double[] mFruitList; | |
public String[] mFruitName; | |
public void food(){ | |
mFruitList = new double[3]; | |
mFruitList[APPLE] = 3; | |
mFruitList[BANANA] = 3; | |
mFruitList[ORANGE] = 4; | |
mFruitName = new String[3]; | |
mFruitName[APPLE] = "Apples"; | |
mFruitName[BANANA] = "Bananas"; | |
mFruitName[ORANGE] = "Oranges"; | |
fruit = 10; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment