@@ -0,0 +1,2968 @@
+package com.samovich.cop2800.chapter14;%0A%0Aimport javax.swing.*;%0Aimport java.awt.*;%0Aimport java.awt.event.ItemEvent;%0Aimport java.awt.event.ItemListener;%0A%0A/**%0A * Filename JResortCalculator.java%0A * Created by Valery Samovich%0A * Written on 7/19/2016%0A */%0Apublic class JResortCalculator extends JFrame implements ItemListener %7B%0A    // declare constants, objects%0A    final int BASE_PRICE = 200;%0A    final int WEEKEND_PREMIUM = 100;%0A    final int BREACKFAST_PREMIUM = 20;%0A    final int GOLF_PREMIUM = 75;%0A    int totalPrice = BASE_PRICE;%0A    JCheckBox weekendBox = new JCheckBox(%22Weekend premium $%22 + WEEKEND_PREMIUM, false);%0A    JCheckBox breakfastBox = new JCheckBox(%22Breakfast $%22 + BREACKFAST_PREMIUM, false);%0A    JCheckBox golfBox = new JCheckBox(%22Golf $%22 + GOLF_PREMIUM, false);%0A    JLabel resortLabel = new JLabel(%22Resort Price Calculator%22);%0A    JLabel priceLabel = new JLabel(%22The price for your stay is%22);%0A    JTextField totPrice = new JTextField(4);%0A    JLabel optionExplainLabel = new JLabel(%22Base price for a room is $%22 + BASE_PRICE + %22.%22);%0A    JLabel optionExplainLabel2 = new JLabel(%22Check the options you want.%22);%0A%0A    /**%0A     * Constructor%0A     */%0A    public JResortCalculator () %7B%0A        super(%22Resort Price Estimator%22);%0A        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A        setLayout(new FlowLayout());%0A        add(resortLabel);%0A        add(optionExplainLabel);%0A        add(optionExplainLabel2);%0A        add(weekendBox);%0A        add(breakfastBox);%0A        add(golfBox);%0A        add(priceLabel);%0A        add(totPrice);%0A        totPrice.setText(%22$%22 + totalPrice);%0A        weekendBox.addItemListener(this);%0A        breakfastBox.addItemListener(this);%0A        golfBox.addItemListener(this);%0A    %7D%0A%0A    /**%0A     * Method that executes when  the user selects oe deselects%0A     * @param event%0A     */%0A    public void itemStateChanged (ItemEvent event) %7B%0A        Object source = event.getSource();%0A        int select = event.getStateChange();%0A%0A        if(source == weekendBox) %7B%0A            if (select == ItemEvent.SELECTED) %7B%0A                totalPrice += WEEKEND_PREMIUM;%0A            %7D else %7B%0A                totalPrice -= WEEKEND_PREMIUM;%0A            %7D%0A        %7D else if(source == breakfastBox) %7B%0A            if(select == ItemEvent.SELECTED) %7B%0A                totalPrice += BREACKFAST_PREMIUM;%0A            %7D else %7B%0A                totalPrice -= BREACKFAST_PREMIUM;%0A            %7D%0A        %7D else %7B // if(source == golfBox) by default%0A            if (select == ItemEvent.SELECTED) %7B%0A                totalPrice += GOLF_PREMIUM;%0A            %7D else %7B%0A                totalPrice -= GOLF_PREMIUM;%0A            %7D%0A            totPrice.setText(%22$%22 + totalPrice);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        // declare objects, fields%0A        JResortCalculator aFrame = new JResortCalculator();%0A        final int WIDTH = 300;%0A        final int HEIGHT = 200;%0A        aFrame.setSize(WIDTH, HEIGHT);%0A        aFrame.setVisible(true);%0A    %7D%0A%7D%0A%0A%0A

Add ItemListener example