Created
December 5, 2012 20:46
-
-
Save josefdlange/4219337 to your computer and use it in GitHub Desktop.
Class to hold flag data given user input and (potentially) draw it.
This file contains hidden or 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
| import javax.swing.*; | |
| import java.lang.*; | |
| class FlagDrawer { | |
| private int countryCode; | |
| private int flagWidth; | |
| private int flagHeight; | |
| public static void main(String args[]) { | |
| int inputCountry = FlagDrawer.getInputCountry(); | |
| int inputSize = FlagDrawer.getInputSize(); | |
| FlagDrawer flag = new FlagDrawer(inputCountry, inputSize); | |
| flag.drawFlag(); | |
| } | |
| public FlagDrawer(int country, int size) { | |
| countryCode = country; | |
| flagHeight = size; | |
| flagWidth = size * 2; | |
| } | |
| public void drawFlag() { | |
| // Code to draw flag using the fields in our object. | |
| // Just showing the values for now in message dialogs. | |
| JOptionPane.showMessageDialog(null, countryCode, "Country", JOptionPane.INFORMATION_MESSAGE); | |
| JOptionPane.showMessageDialog(null, flagHeight, "Height", JOptionPane.INFORMATION_MESSAGE); | |
| JOptionPane.showMessageDialog(null, flagWidth, "Width", JOptionPane.INFORMATION_MESSAGE); | |
| } | |
| public static int getInputCountry() { | |
| String input = JOptionPane.showInputDialog("Please input a country code."); | |
| return Integer.parseInt(input); | |
| } | |
| public static int getInputSize() { | |
| String input = JOptionPane.showInputDialog("Please input the height you'd like your flag to be."); | |
| return Integer.parseInt(input); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment