So I'm basically new to Java. I have c++ experience but there are slight differences. Right now I'm trying to create a simple version of a complex idea. I don't know why I put myself into these positions but I really want to learn and I feel like diving in is the best way to go about it. For some reason the program is not working and I think it has something to do with the fact that I'm a n00b. Can someone please help a sister out? Thanks in advance.
I'd also like your opinions on the GUI automated code builder for netbeans? Do you think I should go old school while I am learning the syntax or are things like this the way of the future?
package ermersestimating; /** * * @author Krystyna */ public class Estimating { private String jobName; private String supplier; private String pipeType; private String pipeSize; private int quantity; private double unitPrice; private double totalPrice; public Estimating(String jobName, String supplier, String pipeType, String pipeSize, int quantity, double unitPrice, double totalPrice) { this.jobName = jobName; this.supplier = supplier; this.pipeType = pipeType; this.pipeSize = pipeSize; this.quantity = quantity; this.unitPrice = unitPrice; this.totalPrice = totalPrice; } public String getJobName() { return jobName; } public void setJobName(String jobName) { this.jobName = jobName; } public String getPipeSize() { return pipeSize; } public void setPipeSize(String pipeSize) { this.pipeSize = pipeSize; } public String getPipeType() { return pipeType; } public void setPipeType(String pipeType) { this.pipeType = pipeType; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public String getSupplier() { return supplier; } public void setSupplier(String supplier) { this.supplier = supplier; } public double getTotalPrice() { return totalPrice; } public void setTotalPrice(double totalPrice) { this.totalPrice = totalPrice; } public double getUnitPrice() { return unitPrice; } public void setUnitPrice(double unitPrice) { this.unitPrice = unitPrice; } @Override public String toString() { return "Job Name: " + jobName + " Supplier: " + supplier + " Pipe Type: " + pipeType + " Pipe Size:" + pipeSize + " Quantity: " + quantity + " Unit Price: " + unitPrice + " TotalPrice: " + (unitPrice*quantity) ; } public static void main(String [] args){ } }
@Action public void getEstimate() throws IOException { [B] //the call below is causing the following error:constructor can not be applied to given types.. found: no arguments reason: actual and formal argument lists differ in length[/B] Estimating Estimate = new Estimating(); double cPipe; double gPipe; double pPipe; //sets Job name Estimate.setJobName(jTextField_Name.getText()); //if copper radio button has focus while(jRadioButton_Copper.hasFocus()){ //price for length of copper pipe cPipe = 15.00; //if statement to determine which supplier is selected if(jCheckBox_Ferg.isSelected()){ Estimate.setSupplier("Ferguson"); Estimate.setPipeType("Copper"); double fergMultiplier = .15; double f = (cPipe * fergMultiplier); double fPrice = (f + cPipe); //sets unit price Estimate.setUnitPrice(fPrice); } else if (jCheckBox_Lion.isSelected()){ Estimate.setSupplier("Lion"); Estimate.setPipeType("Copper"); double lionMultiplier = .20; double l = (cPipe * lionMultiplier); double lPrice = l + cPipe; //sets unit price Estimate.setUnitPrice(lPrice); } else if (jCheckBox_Hughes.isSelected()){ Estimate.setSupplier("Hughes"); Estimate.setPipeType("Copper"); double hughesMultiplier = .14; double h = (cPipe * hughesMultiplier); double hPrice = h + cPipe; //sets unit price Estimate.setUnitPrice(hPrice); } //if galvanized button has focus while(jRadioButton_Galv.hasFocus()){ gPipe = 20.00; if(jCheckBox_Ferg.isSelected()){ Estimate.setSupplier("Ferguson"); Estimate.setPipeType("Galvanized"); double fergMultiplier = .22; double f = (gPipe * fergMultiplier); double fPrice = (f + gPipe); //sets unit price Estimate.setUnitPrice(fPrice); } else if (jCheckBox_Lion.isSelected()){ Estimate.setSupplier("Lion"); Estimate.setPipeType("Galvanized"); double lionMultiplier = .23; double l = (gPipe * lionMultiplier); double lPrice = l + gPipe; //sets unit price Estimate.setUnitPrice(lPrice); } else if (jCheckBox_Hughes.isSelected()){ Estimate.setSupplier("Hughes"); Estimate.setPipeType("Copper"); double hughesMultiplier = .26; double h = (gPipe * hughesMultiplier); double hPrice = h + gPipe; //sets unit price Estimate.setUnitPrice(hPrice); } } //if PVC button has focus while(jRadioButton_Pvc.hasFocus()){ pPipe = 10.00; if(jCheckBox_Ferg.isSelected()){ Estimate.setSupplier("Ferguson"); Estimate.setPipeType("PVC"); double fergMultiplier = .12; double f = (pPipe * fergMultiplier); double fPrice = (f + pPipe); //sets unit price Estimate.setUnitPrice(fPrice); } else if (jCheckBox_Lion.isSelected()){ Estimate.setSupplier("Lion"); Estimate.setPipeType("Galvanized"); double lionMultiplier = .09; double l = (pPipe * lionMultiplier); double lPrice = l + pPipe; //sets unit price Estimate.setUnitPrice(lPrice); } else if (jCheckBox_Hughes.isSelected()){ Estimate.setSupplier("Hughes"); Estimate.setPipeType("Copper"); double hughesMultiplier = .11; double h = (pPipe * hughesMultiplier); double hPrice = h + pPipe; //sets unit price Estimate.setUnitPrice(hPrice); } } // gets quantity value int quantity = ((Integer)jSpinner_Quantity.getValue()).intValue(); Estimate.setQuantity(quantity); //gets size of pipe String size = ((String)jComboBox_Size.getSelectedItem()); Estimate.setPipeSize(size); try { //writes to file FileWriter p = new FileWriter("quote.txt", true); p.append(Estimate.toString()); p.close(); jTextField_Name.setText(""); } catch (FileNotFoundException ex) { Logger.getLogger(Estimating.class.getName()).log(Level.SEVERE, null, ex); } } } //appends data to textArea @Action public void retrieve() throws FileNotFoundException { FileReader fr = new FileReader("quote.txt"); Scanner s = new Scanner(fr); while (s.hasNext()) jTextArea_Quote.append( "\n" + s.nextLine()); } //clears out textArea for the quote tab @Action public void reset() { jTextArea_Quote.setText(""); } //clears the textfield and resets checkboxes/radiobutton to default. @Action public void clearMain() { jTextField_Name.setText(""); jCheckBox_Ferg.setSelected(true); jCheckBox_Hughes.setSelected(false); jCheckBox_Lion.setSelected(false); jComboBox_Size.setSelectedItem(0); jSpinner_Quantity.setValue(0); jRadioButton_Copper.setSelected(true); }