Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

CIS355 Final Project - Java Pool Company

Seeker
Seeker 


Here is your assignment: You work for a Landscape architect. They have asked you to be a part of their team as they need a computer programmer, analyst, and designer to aid them in calculating engineering specification. Specifically, you have been assigned to the Pools, Hot Tubs, and Spas section of their landscaping team. Your skills will be needed in creating a GUI program that calculates engineering specifications. This assignment is due in Week 7, but it is suggested that you begin working on the final project assignment in Week 5, which should give you ample time to complete the project. You will find that all the lectures, Quick Test Programs, and Lab assignments will prepare you for the final project. Final Project Overview This document provide a sample of what is possible, and could lead to a project worth the maximum grade of 100% Something to think about!!! Do not think this is what you have to do to get the maximum number of points. It is just a sample! You are only bound by your programming ability. Please do not try and do more than you are capable of. Think, plan, design and code YOUR final project. This is your opportunity to show off your skills! Overall Appearance Tabs should be used in this application. At a minimum, 4 fully functioning tabs should be designed – the Pools tab, the Hot Tubs tab, the customer tab and the Contractors tab. General Tab The first tab simply displays the current date. An Exit button is provided in this tab, as well as all others. (For all buttons throughout the application, mnemonic values are set.) Options Tab The user should be able to change the company name in the Options tab. Customers Tab The Customers tab allows the user to add new customers and checks for the existence of the customer.txt file in the directory where the program is located. If the file does not exist, the program tells the customer in the Message Area at the bottom. The Customer Display will give a brief explanation of the user’s options. Add Customer When the user clicks Add Customer, an entry window should appear. If the customer.txt file does not exist, the program tells the customer in the Message Area at the bottom. In this window, the user can enter customers; the information entered will be stored as entered. Clicking Add Customer will attempt to write the information to customer.txt. The user should receive an indication when a customer is added successfully. After a customer has been added and the Customers window is closed, the user can click Refresh to refresh the Customer Display area, which will display the contents of the customer.txt file. Contractor Tab The Contractor tab functions in exactly the same way as the Customers tab. The filename for contractors is contract.txt. Pools Tab The Pools tab should perform a calculation. After a length, width, and depth have been entered, the user can click Calculate Volume and the program will display the calculated volume (length * width * depth in cubic feet). Exception handling is used here to catch exceptions, including incomplete forms, invalid entries, and combinations of these. Incomplete forms: Invalid input: Combination invalid input/incomplete input: Hot Tubs Tab The Hot Tubs tab allows for round and oval tubs’ volumes to be calculated. Round Tub When Round Tub is selected, the user cannot fill out the width field since we’re dealing with a circle. After filling out the length and depth fields, the Calculate Volume button will display the volume (Pi * ((length/2)^2) * depth). The width is automatically set to the same value as the length, and the user is informed. Again, exception handling is used here. Oval Tub When Oval Tub is selected, the width field is opened up: The formula used to calculate the volume is (Pi * (length/2 * width/2)) * depth. As with the Pools tab, the same error messages should be displayed in case of no input/invalid values. Temp Calc Tab The Temp Calc tab offers a temperature converter (Celsius <-> Fahrenheit). The user enters a temperature, and selects either C or F. The field after the Result display will display the opposite (if C is selected, field will display F; if F is selected, field will display C). Attachments Tags Clarifications

Answers

JAVA Swing Pool Company

Seeker
Seeker 



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

public class Viewer extends JFrame{
JTabbedPane tabbedPane = new JTabbedPane();
JPanel generalPanel = new JPanel();
JPanel optionsPanel = new JPanel();
JPanel customerPanel = new JPanel();
JPanel contractorsPanel = new JPanel();
JPanel poolsPanel = new JPanel();
JPanel hottubsPanel = new JPanel();
JPanel tempPanel = new JPanel();
JPanel lengthPanel = new JPanel();
JPanel [] panels = {generalPanel, optionsPanel, customerPanel, contractorsPanel, poolsPanel,
hottubsPanel, tempPanel, lengthPanel};
JTextField txtChngCompName, poolLength, poolWidth, poolDepth, poolVolume, tubLength, tubWidth, tubDepth, tubVolume;
JTextField txtTemp, txtResult, mm, meters, yards, feet, inches;
JButton setName,addCustomer, addContractor, calcPoolVolume, calcTubVolume;
JButton custRefresh, cntrRefresh, convertTemp, convertLength;
JTextArea custTxtArea,custMessage, cntrTxtArea, cntrMessage;
JRadioButton round, oval;
JComboBox degree;
JLabel degCel;

public Viewer()
{
super("Business Name"); // Add business name here
addWindowListener(new WindowHandler());
buildGUI();
setSize(400,400);
setLocation(400,260);
setResizable(false);
setVisible(true);
}

public Viewer(String title)
{
super(title);
addWindowListener(new WindowHandler());
buildGUI();
setSize(400,400);
setLocation(400,260);
setVisible(true);
}

void buildGUI()
{
String [] tabs = {"General","Options","Customers","Contractors","Pools","Hot Tubs","Temp Calc",
"Length Calc"};
for(int i = 0; i < tabs.length; ++i)
tabbedPane.addTab(tabs[i], null, panels[i]);
addComponentsToTabs();
add("Center",tabbedPane);
}

void addComponentsToTabs(){
setupGeneralPanel();
setupOptionsPanel();
setupCustomerPanel();
setupContractorPanel();
setupPoolsPanel();
setupHottubsPanel();
setupTempPanel();
setupLengthPanel();
}

void setupGeneralPanel()
{
generalPanel.setLayout(new FlowLayout());
Date today = new Date();
JLabel message = new JLabel("Today's Date: " + today.toString());
generalPanel.add(message);
JButton exit = new JButton("Exit");
exit.addActionListener(new ExitButtonHandler());
generalPanel.add(exit);
}

void setupOptionsPanel()
{
optionsPanel.setLayout(new BorderLayout());
JPanel northPanel = new JPanel();
northPanel.setLayout(new GridLayout(3,1));
JLabel message = new JLabel(" Change Company Name");
txtChngCompName = new JTextField(40);
setName = new JButton("Set New Name");
JButton exit = new JButton("Exit");
JPanel bottom = new JPanel();
bottom.setLayout(new FlowLayout());
exit.addActionListener(new ExitButtonHandler());
setName.addActionListener(new ButtonHandler());
bottom.add(setName);
bottom.add(exit);
northPanel.add(message);
northPanel.add(txtChngCo...
Attachments
screenshot.jpg (42 K) Download Preview

pool .zip (48 K) Download


























































Preview
org.eclipse.mylyn.tasklist.repositories.savePassword="true" org.eclipse.mylyn.tasklist.repositories.httpauth.savePassword="true" org.eclipse.mylyn.tasklist.repositories.proxy.savePassword="true" label="Eclipse.org" category="org.eclipse.mylyn.category.bugs"/><TaskRepository kind="local" url="local"

Preview
org.eclipse.mylyn.tasklist.repositories.savePassword="true" org.eclipse.mylyn.tasklist.repositories.httpauth.savePassword="true" org.eclipse.mylyn.tasklist.repositories.proxy.savePassword="true" label="Eclipse.org" category="org.eclipse.mylyn.category.bugs"/><TaskRepository kind="local" url="local"

Preview
Contractor,123

Preview
Contractor,123

Preview
Joe

Preview
Joe

Preview
JLabel city = new JLabel("City"); JLabel state = new JLabel("State"); JLabel zip = new JLabel("Zip"); JLabel phone = new JLabel("Phone"); panel.add(cust); custName = new JTextField(23); panel.add(custName); custAddress = new JTextField(27); panel.add(address); panel.add(custAddress); custCity = new JTextField(30); panel.add(city); panel.add(custCity);

Preview
JLabel city = new JLabel("City"); JLabel state = new JLabel("State"); JLabel zip = new JLabel("Zip"); JLabel phone = new JLabel("Phone"); panel.add(cust); custName = new JTextField(23); panel.add(custName); custAddress = new JTextField(27); panel.add(address); panel.add(custAddress); custCity = new JTextField(30); panel.add(city); panel.add(custCity);

Preview
e) { if(e.getSource() == close) dispose(); else if(e.getSource() == addCustomer) { try{ BufferedWriter cust = new BufferedWriter(new FileWriter("db\\customer.txt", true)); cust.write(custName.getText() + ","); cust.write(custAddress.getText() + ","); cust.write(custCity.getText() + ","); cust.write(cmbState.getSelectedItem().toString() + ","); cust.write(custZip.getText() + ","); cust.write(custPhone.getText() + "\n");

Preview
e) { if(e.getSource() == close) dispose(); else if(e.getSource() == addCustomer) { try{ BufferedWriter cust = new BufferedWriter(new FileWriter("db\\customer.txt", true)); cust.write(custName.getText() + ","); cust.write(custAddress.getText() + ","); cust.write(custCity.getText() + ","); cust.write(cmbState.getSelectedItem().toString() + ","); cust.write(custZip.getText() + ","); cust.write(custPhone.getText() + "\n");

Preview
class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent

Preview
class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent

Preview
contractorMessage = new JTextArea(4,50); contractorMessage.setEditable(false); this.add(contractorMessage, BorderLayout.SOUTH); } private JPanel buildCenterPanel(){ JPanel centerPanel = new JPanel(); centerPanel.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler()); centerPanel.add(exit); addContractor = new JButton("Add New Contractor"); addContractor.addActionListener(new ButtonHandler());

Preview
contractorMessage = new JTextArea(4,50); contractorMessage.setEditable(false); this.add(contractorMessage, BorderLayout.SOUTH); } private JPanel buildCenterPanel(){ JPanel centerPanel = new JPanel(); centerPanel.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler()); centerPanel.add(exit); addContractor = new JButton("Add New Contractor"); addContractor.addActionListener(new ButtonHandler());

Preview
obj; while(st.hasMoreTokens()){ obj = st.nextToken(); custTxtArea.append(obj + " "); } custTxtArea.append("\n"); } in.close(); }catch(Exception ex){ System.out.println(ex); try{ in.close(); }catch(Exception e){ System.out.println(e); } } } private class ButtonHandler implements ActionListener{ public void

Preview
obj; while(st.hasMoreTokens()){ obj = st.nextToken(); custTxtArea.append(obj + " "); } custTxtArea.append("\n"); } in.close(); }catch(Exception ex){ System.out.println(ex); try{ in.close(); }catch(Exception e){ System.out.println(e); } } } private class ButtonHandler implements ActionListener{ public void

Preview
static final long serialVersionUID = 1L; public GeneralPanel(){ this.setLayout(new FlowLayout()); Date today = new Date();

Preview
static final long serialVersionUID = 1L; public GeneralPanel(){ this.setLayout(new FlowLayout()); Date today = new Date();

Preview
(ft):")); panel3.add(tubWidth); this.add(panel3); JPanel panel4 = new JPanel(); panel4.setLayout(new FlowLayout()); tubDepth = new JTextField(10); panel4.add(new JLabel("Enter the tub's depth (ft):")); panel4.add(tubDepth); this.add(panel4); JPanel panel5 = new JPanel(); panel5.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler());

Preview
(ft):")); panel3.add(tubWidth); this.add(panel3); JPanel panel4 = new JPanel(); panel4.setLayout(new FlowLayout()); tubDepth = new JTextField(10); panel4.add(new JLabel("Enter the tub's depth (ft):")); panel4.add(tubDepth); this.add(panel4); JPanel panel5 = new JPanel(); panel5.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler());

Preview
BorderLayout.NORTH); this.add(buildCenterPanel(), BorderLayout.CENTER); } private JPanel buildNorthPanel(){ JPanel northPanel = new JPanel(); northPanel.setLayout(new GridLayout(2,5)); mm = new JTextField(5); meters = new JTextField(5); yards = new JTextField(5); feet = new JTextField(5); inches = new JTextField(5); northPanel.add(new JLabel("Millimeters"));

Preview
BorderLayout.NORTH); this.add(buildCenterPanel(), BorderLayout.CENTER); } private JPanel buildNorthPanel(){ JPanel northPanel = new JPanel(); northPanel.setLayout(new GridLayout(2,5)); mm = new JTextField(5); meters = new JTextField(5); yards = new JTextField(5); feet = new JTextField(5); inches = new JTextField(5); northPanel.add(new JLabel("Millimeters"));

Preview
new JLabel(" Change Company Name"); northPanel.add(message); txtChngCompName = new JTextField(40); northPanel.add(txtChngCompName); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); this.setName = new JButton("Set New Name"); this.setName.addActionListener(new ButtonHandler()); bottom.add(this.setName); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ExitButtonHandler()); bottom.add(btnExit);

Preview
new JLabel(" Change Company Name"); northPanel.add(message); txtChngCompName = new JTextField(40); northPanel.add(txtChngCompName); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); this.setName = new JButton("Set New Name"); this.setName.addActionListener(new ButtonHandler()); bottom.add(this.setName); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ExitButtonHandler()); bottom.add(btnExit);

Preview
depth (ft):")); panel3.add(poolDepth); this.add(panel3); JPanel panel4 = new JPanel(); panel4.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler()); calcPoolVolume = new JButton("Calculate Volume"); calcPoolVolume.addActionListener(new ButtonHandler()); panel4.add(calcPoolVolume); panel4.add(exit); this.add(panel4); JPanel panel5 = new JPanel(); panel5.setLayout(new FlowLayout());

Preview
depth (ft):")); panel3.add(poolDepth); this.add(panel3); JPanel panel4 = new JPanel(); panel4.setLayout(new FlowLayout()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler()); calcPoolVolume = new JButton("Calculate Volume"); calcPoolVolume.addActionListener(new ButtonHandler()); panel4.add(calcPoolVolume); panel4.add(exit); this.add(panel4); JPanel panel5 = new JPanel(); panel5.setLayout(new FlowLayout());

Preview
javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import poolcompany.handlers.ExitButtonHandler; public class TempPanel extends JPanel{ private static final long serialVersionUID = 1L; private JLabel degCel, result; private JTextField txtResult, txtTemp; private JButton convertTemp; private JComboBox degree; public TempPanel(){ this.setLayout(new GridLayout(8,1)); JPanel

Preview
javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import poolcompany.handlers.ExitButtonHandler; public class TempPanel extends JPanel{ private static final long serialVersionUID = 1L; private JLabel degCel, result; private JTextField txtResult, txtTemp; private JButton convertTemp; private JComboBox degree; public TempPanel(){ this.setLayout(new GridLayout(8,1)); JPanel

Preview
setLocation(400,260); setResizable(false); setVisible(true); } public Viewer(String title) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); buildGUI(); setSize(400,400); setLocation(400,260); setResizable(false); setVisible(true); } void buildGUI() { tabbedPane.add("General", new GeneralPanel()); tabbedPane.add("Options", new OptionsPanel(this));

Preview
setLocation(400,260); setResizable(false); setVisible(true); } public Viewer(String title) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); buildGUI(); setSize(400,400); setLocation(400,260); setResizable(false); setVisible(true); } void buildGUI() { tabbedPane.add("General", new GeneralPanel()); tabbedPane.add("Options", new OptionsPanel(this));

Screenshots
Screenshot
Purchase Answer

Java Swing Pool Company - Updated

Seeker
Seeker 



Java eclipse project with completed unit conversion panel and temp panel. All 8 panels functioning. Attachments
PoolCompany.zip (283 K) Download




























Preview

Preview
url="local" version="1" encoding="UTF-8" timezone="America/New_York" org.eclipse.mylyn.tasklist.repositories.proxy.usedefault="true" org.eclipse.mylyn.tasklist.repositories.savePassword="true" org.eclipse.mylyn.tasklist.repositories.httpauth.savePassword="true"

Preview
Contractor,123

Preview
Joe

Preview
new JTextField(10); panel.add(zip); panel.add(custZip); panel.add(phone); panel.add(custPhone); addCustomer = new JButton("Add Contractor"); close = new JButton("Close"); delete = new JButton("Delete Contractor"); addCustomer.addActionListener(new ButtonHandler()); close.addActionListener(new ButtonHandler()); delete.addActionListener(new ButtonHandler()); panel.add(addCustomer); panel.add(close); panel.add(delete); message = new JTextArea(3,30); message.setEditable

Preview
FileWriter("db\\customer.txt", true)); cust.write(custName.getText() + ","); cust.write(custAddress.getText() + ","); cust.write(custCity.getText() + ","); cust.write(cmbState.getSelectedItem().toString() + ","); cust.write(custZip.getText() + ","); cust.write(custPhone.getText() + "\r\n"); cust.newLine(); cust.flush(); cust.close(); dispose(); }catch(IOException m){ JOptionPane.showMessageDialog(null, "You must enter all fields", "Error", JOptionPane.OK_OPTION); }

Preview
void actionPerformed(ActionEvent e) { if (e.getActionCommand() == "Exit")

Preview
String line; while((line = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(line, ","); String obj; while(st.hasMoreTokens()) { obj = st.nextToken(); contractorTextArea.append(obj + " "); } contractorTextArea.append("\n"); } in.close(); }catch(IOException m){ System.out.println(m); try{ in.close(); }catch(Exception

Preview
static final long serialVersionUID = 1L; private static final String customerFileLocation = "db\\customer.txt"; private JTextArea custTxtArea, custMessage; private JButton btnNewCustomer, btnCustRefresh; public CustomerPanel(){ this.setLayout(new BorderLayout()); custTxtArea = new JTextArea(13,50); custTxtArea.setEditable(Boolean.FALSE); custTxtArea.setAutoscrolls(true); JScrollPane scroll = new JScrollPane(custTxtArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,

Preview
package poolcompany.panels; import java.awt.FlowLayout; import java.util.Date; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import poolcompany.handlers.ExitButtonHandler; public class GeneralPanel extends

Preview
tubVolume.setText(Double.toString(volume)); tubLength.setText(""); tubWidth.setText(""); tubDepth.setText(""); }catch(Exception f){ JOptionPane.showMessageDialog(null, "You must enter a number", "Error", JOptionPane.OK_OPTION); } }else if(oval.isSelected()) { try{ tubWidth.setText(""); double length = Double.parseDouble(tubLength.getText()); double depth = Double.parseDouble(tubDepth.getText()); double volume = length * length * depth;

Preview
FocusListener{ @Override public void focusGained(FocusEvent e) { /*if(e.getSource() == mm){ meters.setText(""); yards.setText(""); feet.setText(""); inches.setText(""); }else if(e.getSource() == meters){ mm.setText(""); yards.setText(""); feet.setText(""); inches.setText(""); }else if(e.getSource() == yards){ meters.setText(""); mm.setText(""); feet.setText(""); inches.setText(""); }else

Preview
private JPanel buildNorthPanel(){ JPanel northPanel = new JPanel(); northPanel.setLayout(new GridLayout(3,1)); JLabel message = new JLabel(" Change Company Name"); northPanel.add(message); txtChngCompName = new JTextField(40); northPanel.add(txtChngCompName); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); this.setName = new JButton("Set New Name");

Preview
try{ double length = Double.parseDouble(poolLength.getText()); double width = Double.parseDouble(poolWidth.getText()); double depth = Double.parseDouble(poolDepth.getText()); double volume = length * width * depth; poolVolume.setText(Double.toString(volume)); poolLength.setText(""); poolWidth.setText(""); poolDepth.setText(""); }catch(Exception f){ JOptionPane.showMessageDialog(null, "You must enter a number", "Error", JOptionPane.OK_OPTION); } }

Preview
ButtonHandler()); JButton exit = new JButton("Exit"); exit.addActionListener(new ExitButtonHandler()); panel[2].add(convertTemp); panel[2].add(exit); for(int i = 0; i < panel.length; i++) this.add(panel[i]); } private class ButtonHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ if(e.getSource() == convertTemp) { double temp =

Preview
} public Viewer(String title) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); buildGUI(); setSize(400,400); setLocation(400,260); setResizable(false); setVisible(true); } void buildGUI() { tabbedPane.add("General", new GeneralPanel()); tabbedPane.add("Options", new OptionsPanel(this)); tabbedPane.add("Customers", new CustomerPanel()); tabbedPane.add("Contractors", new

Preview

Preview

Preview

Preview

Preview

Preview

Preview

Screenshots
Screenshot
Screenshot
Screenshot
Screenshot
Screenshot
Screenshot
Screenshot
Screenshot
Purchase Answer

You work for a Landscape architect. They have asked you to be a part of their team as they need a co

Luminariah
Luminariah 



The importance of a graphical user interface in programming is paramount in being successful in the business industry. This project incorporates GUI techniques with other tools that you have learned about in this class.

Here is your assignment: You work for a Landscape architect. They have asked you to be a part of their team as they need a computer programmer, analyst, and designer to aid them in calculating engineering specification. Specifically, you have been assigned to the Pools, Hot Tubs, and Spas section of their landscaping team. Your skills will be needed in creating a GUI program that calculates engineering specifications.

This assignment is due in Week 7, but it is suggested that you begin working on the project in Week 5, which should give you ample time to complete the project. You will find that all the lectures, Quick Test Programs, and Lab assignments will prepare you for the Course Project.
Attachments
FinalProject.zip (46 K) Download



































Preview
contentPane.add(lblZip); textFieldZIP = new JTextField(); textFieldZIP.setBounds(157, 114, 75, 20); contentPane.add(textFieldZIP); textFieldZIP.setColumns(10); lblPhone = new JLabel("Phone"); lblPhone.setBounds(242, 117, 46, 14); contentPane.add(lblPhone); textFieldPhone = new JTextField(); textFieldPhone.setBounds(285, 114, 139, 20); contentPane.add(textFieldPhone); textFieldPhone.setColumns(10); btnAddCustomer = new JButton("Add

Preview
import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JComboBox; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class AddCustomer extends JFrame { private JPanel conte

Preview
args */ public static void main(String[] args) {

Preview
panel, null); panel.setLayout(null); JButton btnExit = new JButton("Exit"); btnExit.setMnemonic('E'); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); btnExit.setBounds(244, 24, 89, 23); panel.add(btnExit); //Create the date label and populate using the method getDate implemented below

Screenshots
Purchase Answer