Adding a Restock Fee

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #16
    Originally posted by JosAH
    Lol!

    kind regards,

    Jos :-)
    I just googled it.
    Silly me

    Comment

    • nexcompac
      New Member
      • May 2007
      • 22

      #17
      You googled Lysol? Funny....
      For some reason I am having troubles with TextPad and the way it complies on my home computer. My laptop works just fine, but I can not use it at work. My work computer does not have permission to install the JDK files and its not worth "tweeking" it at the moment. So, I need to wait until I get home unless you have a way of doing it without requireing the Admin password.

      About the complie stuff. Since my computer has issues, I copy the *.java files into the bin folder of the JDK and then compile from the comand prompt by changing the directory to the bin file and typing javac *.java. This will compile all the java files and give me the *.class files. Then, I can just fire the java files from the cmd too. Does that make sence?

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #18
        Originally posted by nexcompac
        About the complie stuff. Since my computer has issues, I copy the *.java files into the bin folder of the JDK and then compile from the comand prompt by changing the directory to the bin file and typing javac *.java. This will compile all the java files and give me the *.class files. Then, I can just fire the java files from the cmd too. Does that make sence?
        It sort of works but you shouldn't do it like that: add the name of that bin directory
        to your 'path' environment variable and store your .java sources and .class files
        somewhere else in their own directory. You don't pollute that bin directory then.

        kind regards,

        Jos

        Comment

        • nexcompac
          New Member
          • May 2007
          • 22

          #19
          Originally posted by madhoriya22
          Hi,
          luk at ur getRestockFee() method again........ here u r calling value method in ur return statement..... but there is no value method in ur class.....thats why compiler is not able to resolve it... it is not wise to remove the lines where u r getting errors...... instead u should think what u need to resolve this error.... I think r035198x has given u the answer.....defi ne value() method in ur class

          thanks and regards,
          madhoriya
          Ok, so should this be defined in the current class which it resides in or should it be designed in the public main class?

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #20
            Originally posted by nexcompac
            Ok, so should this be defined in the current class which it resides in or should it be designed in the public main class?
            See one of your error messages again:

            Code:
             Product.java:61 cannot find symbol
            symbol  : method value<>
            location: class product
                  return value<> * 0.05;

            Comment

            • nexcompac
              New Member
              • May 2007
              • 22

              #21
              Ok, so now I am getting just one error.
              Again just typing out manually.
              product.java:8: ';' expected
              ^
              1 error

              Here is what I changed

              Code:
              class product implements Comparable 
              {
              private String productName; // class variable that stores the item name
              private int itemNumber; // class variable that stores the item number
              private double unitProduct; // class variable that stores the quantity in stock
              private double priceProduct; // class variable that stores the item price
              private double restockfee
              
              
              /** Creates a new instance of product */
              public product() // Constructor for Product class
              {
              productName = "";
              itemNumber = 0;
              unitProduct = 0.0;
              priceProduct = 0.0;
              restockfee = 0.00;
              }
              public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
              {
              this.productName = productName;
              this.itemNumber = itemNumber;
              this.unitProduct = unitProduct;
              this.priceProduct = priceProduct;
              this.restockfee = restockfee;
              }
              
              public void setProductName(String name) // Method to set the item name
              {
              this.productName = productName;
              }
              public String getProductName() // Method to get the item name
              {
              return productName;
              }
              public void setItemNumber(int number) // Method to set the item number
              {
              this.itemNumber = itemNumber;
              }
              public int getItemNumber() // Method to get the item name
              {
              return itemNumber;
              }
              public void setUnitProduct(double unit) // Method to set the item number
              {
              this.unitProduct = unitProduct;
              }
              public double getUnitProduct() // Method to get the item name
              {
              return unitProduct;
              }
              public void setPriceProduct(double price) // Method to set the item number
              {
              this.priceProduct = priceProduct;
              }
              public double getPriceProduct() // Method to get the item name
              {
              return priceProduct;
              }
              public double setRestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              }
              public double getRestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              }
              
              
              // Calculation method
              public double itemCalculate()
              { 
              return unitProduct * priceProduct; // multiply for total for each item
              
              } // end calculation
              public int compareTo (Object o) // use the compareTo method
              {
              product p = (product)o;
              return productName.compareTo(p.getProductName());
              }
              public double RestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              } // end 
              
              }//end class Supplies

              Comment

              • madhoriya22
                Contributor
                • Jul 2007
                • 251

                #22
                Originally posted by nexcompac
                Ok, so now I am getting just one error.
                private double unitProduct; // class variable that stores the quantity in stock
                private double priceProduct; // class variable that stores the item price
                private double restockfee


                /** Creates a new instance of product */
                public product() // Constructor for Product class
                {
                productName = "";
                itemNumber = 0;
                unitProduct = 0.0;
                priceProduct = 0.0;
                restockfee = 0.00;
                }
                public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
                {
                this.productNam e = productName;
                this.itemNumber = itemNumber;
                this.unitProduc t = unitProduct;
                this.priceProdu ct = priceProduct;
                this.restockfee = restockfee;
                }

                public void setProductName( String name) // Method to set the item name
                {
                this.productNam e = productName;
                }
                public String getProductName( ) // Method to get the item name
                {
                return productName;
                }
                public void setItemNumber(i nt number) // Method to set the item number
                {
                this.itemNumber = itemNumber;
                }
                public int getItemNumber() // Method to get the item name
                {
                return itemNumber;
                }
                public void setUnitProduct( double unit) // Method to set the item number
                {
                this.unitProduc t = unitProduct;
                }
                public double getUnitProduct( ) // Method to get the item name
                {
                return unitProduct;
                }
                public void setPriceProduct (double price) // Method to set the item number
                {
                this.priceProdu ct = priceProduct;
                }
                public double getPriceProduct () // Method to get the item name
                {
                return priceProduct;
                }
                public double setRestockFee() // Method to set the Restocking fee
                {
                return value() * 0.05;
                }
                public double getRestockFee() // Method to set the Restocking fee
                {
                return value() * 0.05;
                }
                [/CODE]
                Hi,
                put a semicolon at the end of this line.....
                Code:
                private double restockfee
                like this
                Code:
                private double restockfee;
                Thanks and regards,
                madhoriya

                Comment

                • nexcompac
                  New Member
                  • May 2007
                  • 22

                  #23
                  ok, so now I am going in circles.....
                  Back to three errors

                  Comment

                  • madhoriya22
                    Contributor
                    • Jul 2007
                    • 251

                    #24
                    Originally posted by nexcompac
                    ok, so now I am going in circles.....
                    Back to three errors
                    Hi,
                    What are the errors....?

                    Thanks and regards,
                    madhoriya

                    Comment

                    • nexcompac
                      New Member
                      • May 2007
                      • 22

                      #25
                      Product.java:61 cannot find symbol
                      symbol : method value<>
                      location: class product
                      return value<> * 0.05;

                      Product.java:65 cannot find symbol
                      symbol : method value<>
                      location: class product
                      return value<> * 0.05;

                      Product.java:82 cannot find symbol
                      symbol : method value<>
                      location: class product
                      return value<> * 0.05;

                      3 errors

                      Comment

                      • nexcompac
                        New Member
                        • May 2007
                        • 22

                        #26
                        Heres what someone pointed out to me.

                        And your problem is that you did not and still have not defined a value() method. Typically, methods need to exist before you use them

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #27
                          Originally posted by nexcompac
                          Heres what someone pointed out to me.
                          Originally posted by someone
                          And your problem is that you did not and still have not defined a value() method. Typically, methods need to exist before you use them
                          That is ever so true; I tried to find the definition of the value() method in your
                          post but it was nowhere to be found. Define a method value() in your class:

                          [code=java]
                          double value() {
                          return //whatever it has to return
                          }
                          [/code]

                          and try again.

                          kind regards,

                          Jos

                          Comment

                          • nexcompac
                            New Member
                            • May 2007
                            • 22

                            #28
                            Originally posted by JosAH
                            That is ever so true; I tried to find the definition of the value() method in your
                            post but it was nowhere to be found. Define a method value() in your class:

                            [code=java]
                            double value() {
                            return //whatever it has to return
                            }
                            [/code]

                            and try again.

                            kind regards,

                            Jos

                            Now I can not take all the credit as my teacher has done most of the work.

                            Code:
                            import java.util.*;
                            
                            public class Company extends product implements Comparable
                            {
                                private String developer;
                                //double total;
                            
                                /** Creates a new instance of Company */
                                public Company()
                                {
                                    super();
                                    String developer ="";
                                    //total =0.0;
                                }
                                public Company(String productName, int itemNumber, double unitProduct, double priceProduct, String developer)
                                {
                                    super(productName, itemNumber, unitProduct, priceProduct);
                                    this.developer = developer;
                                }
                            
                                    public void setDeveloper( String developer)
                                     {
                                        this.developer = developer;
                                     }
                                    public String getDeveloper()
                                     {
                                        return developer;
                                     }
                            
                                    public double itemCalculate()
                                    {
                                        return (super.itemCalculate()*.05)+super.itemCalculate();
                                    }
                            
                                    public int compareTo (Object o) // use the compareTo method
                                    {
                                        product p = (product)o;
                                        return productName.compareTo(p.getProductName());
                                    }
                            
                                    public String toString()
                                    {
                                     return super.toString()+ "\nCompany: "+ developer +"\nPrice with restock fee: $"+itemCalculate();
                                    }
                            }

                            Code:
                            import java.util.*; // program uses class Scanner
                            
                            public class Inventory 
                            {    
                                // main method begins execution of Java application
                               public static void main( String args[]) 
                               {    
                                  product[] myProduct = new product[5];
                                  //Company[] myCompany = new Company[5];
                            
                                    product p1 = new Company("Mad Dash", 20003, 5, 30, "EIDOS");
                                    product p2 = new Company("Fuzion Frenzy", 74512, 2, 10, "MicroSoft");
                                    product p3 = new Company("Time Splitters 2", 20009, 3, 45, "EIDOS");
                                    product p4 = new Company("Night Caster", 74522, 8, 5, "MicroSoft");
                                    product p5 = new Company("Lego Star Wars II", 32976, 1, 50, "LucasArts");
                                    
                                    myProduct[0] = p1;
                                    myProduct[1] = p2;
                                    myProduct[2] = p3;
                                    myProduct[3] = p4;
                                    myProduct[4] = p5;
                                    
                                    double totalValue = 0.0;
                                    
                                    for (int c=0; c < 5; c++)
                                    {
                                        totalValue = totalValue + myProduct[c].itemCalculate();
                                    }
                                    
                                    Arrays.sort(myProduct); // function used to sort arrays
                                    
                                    for(product p: myProduct)
                                    {
                                        System.out.println(p);
                                        System.out.println();
                                    }
                                   System.out.println("Total Inventory value is: $"+totalValue);
                               
                               } //end main
                                
                            } //end Inventory


                            Code:
                            import java.util.*; // program uses any class available
                            
                            class product implements Comparable
                            {
                               public String productName; // class variable that stores the item name
                               private int itemNumber; // class variable that stores the item number
                               private double unitProduct; // class variable that stores the quantity in stock
                               private double priceProduct; // class variable that stores the item price
                            
                                /** Creates a new instance of product */
                                public product() // Constructor for Product class
                                 {
                                    productName = "";
                                    itemNumber = 0;
                                    unitProduct = 0.0;
                                    priceProduct = 0.0;
                                 }
                                public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
                                {
                                    this.productName = productName;
                                    this.itemNumber = itemNumber;
                                    this.unitProduct = unitProduct;
                                    this.priceProduct = priceProduct;
                                }
                            
                                  public void setProductName(String name)  // Method to set the item name
                                   {
                                     this.productName = productName;
                                   }
                                  public String getProductName()  // Method to get the item name
                                   {
                                     return productName;
                                   }
                                  public void setItemNumber(int number)  // Method to set the item number
                                   {
                                     this.itemNumber = itemNumber;
                                   }
                                  public int getItemNumber()  // Method to get the item name
                                   {
                                     return itemNumber;
                                   }
                                   public void setUnitProduct(double unit)  // Method to set the item number
                                   {
                                     this.unitProduct = unitProduct;
                                   }
                                  public double getUnitProduct()  // Method to get the item name
                                   {
                                     return unitProduct;
                                   }
                                   public void setPriceProduct(double price)  // Method to set the item number
                                   {
                                     this.priceProduct = priceProduct;
                                   }
                                  public double getPriceProduct()  // Method to get the item name
                                   {
                                     return priceProduct;
                                   }
                            
                            // Calculation method
                              public double itemCalculate()
                               {
                                    return unitProduct * priceProduct; // multiply for total for each item
                            
                               } // end calculation
                              public int compareTo (Object o) // use the compareTo method
                                {
                                  product p = (product)o;
                                     return productName.compareTo(p.getProductName());
                                }
                            
                              public String toString() // displays products
                              {
                                  return "Title: "+productName+
                                          "\nBarcode: "+itemNumber+
                                          "\nNumber of Xbox games: "+(int)unitProduct+
                                          "\nPrice: $"+priceProduct+
                                          "\nTotal: $"+itemCalculate();
                               } // end toString
                            
                            
                            }//end class Supplies

                            Comment

                            • nexcompac
                              New Member
                              • May 2007
                              • 22

                              #29
                              Originally posted by JosAH
                              That is ever so true; I tried to find the definition of the value() method in your
                              post but it was nowhere to be found. Define a method value() in your class:

                              [code=java]
                              double value() {
                              return //whatever it has to return
                              }
                              [/code]

                              and try again.

                              kind regards,

                              Jos
                              Ok, so what is the best method in proceeding to add the GUI to this?

                              Comment

                              • JosAH
                                Recognized Expert MVP
                                • Mar 2007
                                • 11453

                                #30
                                Originally posted by nexcompac
                                Ok, so what is the best method in proceeding to add the GUI to this?
                                I don't know; I don't know what sort of GUI you have in mind. Have you read
                                about the Swing framework? Look here.

                                kind regards,

                                Jos

                                Comment

                                Working...