Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Beginner help please.

$
0
0
Hey, I am a beginner and my teacher assigned us this task :
Write an application for a construction company to handle a customer's order to build a new home. Use separate ButtonGroups to allow the customer to select one of four models, the number of bedrooms, and a garage type. Assume that the models are the Aspen, $100000; the Brittany, $120000; the Colonial, $180000; or the Dartmoor, $250000. Assume that any model can have two, three, or four bedrooms and that each bedroom adds $10500 to the base price. Assume that garage type can be zero-, one-, two-, or three-car , and that each car adds $7775 to the price.

I have no idea how to use actionlistener to get the price to add up everytime the user checks a checkbox!!
can someone please help, it's due tomorrow!!

i'm not asking for a code, i've tried searching online but nothing helps me make my program!!
can someone just hint or guide me through what i should do next?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JMyNewHome extends JFrame
{

public static void main(String[] arg)
{
JMyNewHome window = new JMyNewHome();
window.setVisible(true);
}

JCheckBox aspen = new JCheckBox("Aspen-$100,000");
JCheckBox brittany = new JCheckBox("Brittany-$120,000");
JCheckBox colonial = new JCheckBox("Colonial-$180,00");
JCheckBox dartmoor = new JCheckBox("Dartmoor-$250,000");
JCheckBox twobed = new JCheckBox("2 Bed-$21,000");
JCheckBox threebed = new JCheckBox("3 Bed-$31,500");
JCheckBox fourbed = new JCheckBox("4 Bed-$42,000");
JCheckBox carzero = new JCheckBox("0 Car-$0");
JCheckBox carone = new JCheckBox("1 Car-$7,775");
JCheckBox cartwo = new JCheckBox("2 Car-$15,550");
JCheckBox carthree = new JCheckBox("3 Car-$23,325");
JLabel price = new JLabel("$0.00");
Container contentPane = getContentPane();
/*	final int aspen = 100000;
final int brittany = 120000;
final int colonial = 180000;
final int dartmoor = 250000;
final int twobed = 21000;
final int threebed = 31500;
final int fourbed = 42000;
final int carzero = 0;
final int carone = 7775;
final int cartwo = 15550;
final int carthree = 23325;
int price = 0;
*/	
public JMyNewHome()
{
setTitle("My New Home");
setLayout(new FlowLayout());
contentPane.add(aspen);
contentPane.add(brittany);
contentPane.add(colonial);
contentPane.add(dartmoor);
contentPane.add(twobed);
contentPane.add(threebed);
contentPane.add(fourbed);
contentPane.add(carzero);
contentPane.add(carone);
contentPane.add(cartwo);
contentPane.add(carthree);
contentPane.add(price);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,150);
ButtonGroup house = new ButtonGroup();
house.add(aspen);
house.add(brittany);
house.add(colonial);
house.add(dartmoor);
ButtonGroup beds = new ButtonGroup();
beds.add(twobed);
beds.add(threebed);
beds.add(fourbed);
ButtonGroup cars = new ButtonGroup();
cars.add(carzero);
cars.add(carone);
cars.add(cartwo);
cars.add(carthree);
ClickButtonListener clickListener = new ClickButtonListener();
aspen.addActionListener(clickListener);
}

public class ClickButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(aspen==ItemEvent.SELECTED)
{
price.setText("100,000");
}
else if(brittany==ItemEvent.SELECTED)
{
price.setText("120,000");
}
}
}


}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>