Question
//java public class AgileWaterfallGUI extends JFrame { private JPanel rootPanel ; private JTextField projectName ; private JSlider peopleOnTeam ; private JCheckBox firmDeadlines ; private JCheckBox
//java public class AgileWaterfallGUI extends JFrame { private JPanel rootPanel; private JTextField projectName; private JSlider peopleOnTeam; private JCheckBox firmDeadlines; private JCheckBox experienceAllPhases; private JCheckBox qualityControl; private JCheckBox earlyIntegration; private JCheckBox earlyWorkingModels; private JButton recommendMethodology; private JLabel recommendation; public final static String AGILE = "Agile"; public final static String WATERFALL = "Waterfall"; public final static String EITHER = "either"; public final static String RECOMMENDATION_TEMPLATE = "%s could use %s"; AgileWaterfallGUI() { setContentPane(rootPanel); pack(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); //TODO any GUI configuration needed //TODO add event handler to read the data entered, and selections made, //TODO recommend a methodology, display in JLabel. // Use the recommendationTemplate to display a String like "Android App should use Agile" } }
==================================================================================================================================
// the whole class in this project is
//java gui
//1. class AgileWaterFallProgram
package agile_waterfall;
/**
* * For this lab, you probably don't need to modify this class. */ public class AgileWaterfallProgram { public static void main(String[] args) { AgileWaterfallGUI gui = new AgileWaterfallGUI(); } }
=====================================================================================
//2.class AgileWaterfallGUI
package agile_waterfall; import javax.swing.*; public class AgileWaterfallGUI extends JFrame { private JPanel mainPanel; public final static String AGILE = "Agile"; public final static String WATERFALL = "Waterfall"; public final static String EITHER = "either"; public final static String RECOMMENDATION_TEMPLATE = "%s could use %s"; AgileWaterfallGUI() { setContentPane(mainPanel); pack(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); //TODO any GUI configuration needed //TODO add event handler to read the data entered, and selections made, //TODO recommend a methodology, display in JLabel. // Use the recommendationTemplate to display a String like "Android App should use Agile" }}
===========================================================================================================================
//3. class DonorProgram
package blood_donor; /** * Main method to start the GUI. * Can do other non-gui-specific app setup here if needed. * For this lab, you probably don't need to modify this class. */ public class DonorProgram { public static void main(String[] args) { DonorGUI gui = new DonorGUI(); } }
===========================================================================================
// 4. class donorGui
package blood_donor; import javax.swing.*; public class DonorGUI extends JFrame { public static final String ELIGIBLE = "Eligible!"; public static final String NOT_ELIGIBLE = "Sorry, not eligible."; public static final String INPUT_ERROR = "Error - enter positive numbers"; private JPanel mainPanel; DonorGUI() { this.setContentPane(mainPanel); pack(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); // TODO add a listener for the checkEligibilityButton // This should verify that the user has entered a positive number // in both the weightTextField and ageTextField JTextField // If either or both are not valid, the resultLable should // display the INPUT_ERROR text. // If both weight and age are positive numbers, use the data // to decide if the user is eligible to be a blood donor. // To be eligible, a person must be 17 or older, // AND weigh 110 lbs or more. // Display the ELIGIBLE text if they are eligible. // Display the NOT_ELIGIBLE text if they are not eligible. } }
=====================================================================================================
// class Garden
package garden; /* * For this lab, you probably don't need to modify this class. * */ class GardenProgram { public static void main(String[] args) { GardenGUI gui = new GardenGUI(); } }
=========================================================================================
//6.class GardenServiceData
package garden; /** * Constants to represent price of each service. * A future program would read these from a data store, and/or permit modification */ public class GardenServiceData { static String[] gardenSizes = {"Small", "Medium", "Large"}; // Prices of services static final double MOWING = 15; static final double LEAF_RAKING = 12; static final double MEDIUM_PRICE_MULTIPLY = 2; static final double LARGE_PRICE_MULTIPLY = 3; // Example gardener contact String, used when generating invoices static final String gardenerContactString = "Rose the Gardener, 123 Main Street, Minneapolis. Telephone 000-000-000"; }
=================================================================
//6. class InvoiceGenerator
package garden; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StrSubstitutor; import java.util.HashMap; /** * You should not need to modify this file, * but you will need to call the methods here. */ public class InvoiceGenerator { static final String GARDENER_CONTACT = "GARDENER_CONTACT"; static final String NAME = "NAME"; static final String ADDRESS = "ADDRESS"; static final String DATE = "DATE"; static final String GARDEN_SIZE = "GARDEN_SIZE"; static final String MOWING = "MOWING"; static final String LEAVES = "LEAVES"; static final String TOTAL = "TOTAL"; static String invoiceTemplate; /* Provide a HashMap with the following keys, and String values. NAME ADDRESS DATE GARDEN_SIZE MOWING LEAVES TOTAL Notice these Strings are provided as constants in this class. For a price, the value should be a String number with 2 decimal places, and no & or other currency symbol, e.g. "28.00" or "14.00" */ public static String generate(HashMap data) { // Add in the gardener info String data.put(GARDENER_CONTACT, GardenServiceData.gardenerContactString); // Create a String Substitutor with the HashMap StrSubstitutor sub = new StrSubstitutor(data); //Use our own template prefix sub.setVariablePrefix("&{"); String invoice = sub.replace(invoiceTemplate); return invoice; } static int width = 80; static String lines[] = { StringUtils.center("************ Garden Services Invoice ************", width), "", "&{GARDENER_CONTACT}", "", "Customer Name: &{NAME}", "Address of garden: &{ADDRESS}", "", "Date of service: &{DATE}", "Size of garden: &{GARDEN_SIZE}", "", "Lawn mowing service charge: $ &{MOWING}", "Leaf raking service charge: $ &{LEAVES}", "", "Total: $ &{TOTAL}", "", "Please send payment to the address above.", "Thank you for your business." } ; static { // Center the lines and concatenate together StringBuilder builder = new StringBuilder(); for (String line: lines) { builder.append(line); builder.append(" "); } invoiceTemplate = builder.toString(); }}
==========================================================================================================
//7. class InvoiceWriter
package garden; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; /** * Handles writing invoices to disk. Invoices are saved in the * directory given by INVOICE_DIRECTORY. * * You should not need to modify this file, but you will need to call methods. */ public class InvoiceWriter { static final String INVOICE_DIRECTORY = "GardeningInvoices"; private static String dateFormatString = "MMM_dd_yyyy"; // e.g. "sep_09_2017" private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatString); static { File invoiceDir = new File(INVOICE_DIRECTORY); try { invoiceDir.mkdir(); } catch (SecurityException e) { if (!invoiceDir.exists()) { System.out.println("ERROR - could not create Invoice Directory. " + INVOICE_DIRECTORY); } // Otherwise, if it exists, presumably it has already been created, so no problem. } } /* Create a valid filename from a date, and the customer's name. Names may have characters that are not permitted in filenames, these must be removed or replaced. This is a very basic solution: remove all characters from customer name that are not A-Z or a-z. This could definitely be improved. There are many names that would be distorted by this method. This would perform poorly on names with characters outside A-Z and a-z. What if a customer has several characters removed from their name? Many characters outside A-Z and a-z range are valid filename characters. A more exhaustive solution to preserve names and create valid filenames would be more work, and more testing. Looking into a 3rd party library to handle this would be recommended in a real program; it's a fairly common problem. You are not required to improve this method; but you are welcome to contribute an improved version if you like :) */ public static String createFileName(String customer, Date date) { String name = removeBannedCharacters(customer); if (name.length() == 0) { name = "Customer"; // Something, if there are no valid filename characters. Can you think of a better solution? Ask the user for a name? } // Format the date into a String String dateString = simpleDateFormat.format(date); String filename = String.format("%s_%s_invoice.txt", name, dateString); return filename; } protected static String removeBannedCharacters(String st) { return st.replaceAll("[^A-Za-z]", ""); } /* Warning! This method overwrites an existing file. A real program * should warn the user that a file with the proposed name exists, and offer them * the choice to overwrite or give a new name. */ public static boolean writeToFile(String filename, String text) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(INVOICE_DIRECTORY, filename)))) { writer.write(text); writer.close(); return true; } catch (IOException e) { System.out.println("Unable to write to file " + filename + ". Error message: " + e.getMessage()); return false; } } }
// instruction
Create a GUI for your Agile or Waterfall program . Add these components to AgileWaterfallGUI.form. Again, use these names. **JTextField projectName** **JSlider peopleOnTeam** This should take values between 1 and 300. Add JLabels with the text "1" at the start, and "300" at the end, to indicate the start and end values. **JCheckBox firmDeadlines** **JCheckBox experienceAllPhases** **JCheckBox qualityControl** **JCheckBox earlyIntegration** **JCheckBox earlyWorkingModels** **JButton recommendMethodology** **JLabel recommendation** Add more JLabels as appropriate, for example, to label the JTextField and JSlider name and max and min values. Your program can re-use the agileOrWaterfall method you wrote in Lab 3. Add a click event listener to the `recommendMethodology` button. When clicked, this button will read the data entered, and recommend Waterfall or Agile or Either for a development method for the project. Display the recommendation in the `recommendation` JLabel. Use the provided Strings `AGILE`, `WATERFALL` and `EITHER` and `RECOMMENDATION_TEMPLATE` to display the result. Your GUI program should use a JLabel and the recommendationTemplate format String provided to display something like Big IBM Project could use Waterfall or My assignment could use Agile or "Banking App could use either"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started