Results 1 to 19 of 19
Like Tree1Likes
  • 1 Post By DiamondSoul

Thread: I need help i have 8 errors can someone pleasehelp me

  1. #1
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default I need help i have 8 errors can someone pleasehelp me

    can i get someone to help me with this:



    class Cameras {

    private String ItemNumber;
    private String ProductName;
    private double UnitsStock;
    private double UnitPrice;
    private String SerialNumber;
    private double InventoryValue;



    public Cameras (String item, String product, double units, double price, String serial) {

    ItemNumber = item;
    ProductName = product;
    UnitsStock = units;
    UnitPrice = price;
    SerialNumber = serial;

    }



    public void setItemNumber (String item) {
    this.ItemNumber = item;
    }

    public String getItemNumber() {
    return ItemNumber;
    }

    public void setProductName (String product) {
    this.ProductName = product;
    }

    public String getProductName() {
    return ProductName;
    }

    public void setUnitsStock (double units) {
    this.UnitsStock = units;
    }

    public double getUnitsStock() {
    return UnitsStock;
    }

    public void setUnitPrice (double price) {
    this.UnitPrice = price;
    }

    public double getUnitPrice() {
    return UnitPrice;
    }

    public void setSerialNumber (String serial) {
    this.SerialNumber = serial;
    }

    public String getSerialNumber() {
    return SerialNumber;
    }





    public double getInventoryValue(){
    return UnitsStock * UnitPrice;

    }



    public double calculateInventory(){
    return UnitPrice * UnitsStock;
    }



    }

    class Manufacturer extends Cameras {
    private String manufacturerName;



    public Camera(int ItemNumber, String ProductName, int UnitsStock, double UnitPrice, String ManufacturerName) {


    ItemNumber = Item;

    ProductName = Product;

    UnitsStock = Units;

    UnitPrice = UnitPrice;

    ManufacturerName = mfgName;

    }



    public void setmanufacturerName(String mfgName) {
    manufacturerName = mfgName;
    }

    public String getmanufacturerName() {
    return manufacturerName;
    }



    public double calculateInventory(){
    return ((UnitPrice * UnitsStock));

    }



    public double getcalculateRestockFee() {
    return getInventoryValue();
    }


    }

  2. #2
    DiamondSoul is offline Member
    Join Date
    Oct 2011
    Posts
    83
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    This problem is in your constructor for Manufacturer. Change this line:


    public Camera(int ItemNumber, String ProductName, int UnitsStock, double UnitPrice, String ManufacturerName) {


    to this:


    public Manufacturer(int ItemNumber, String ProductName, int UnitsStock, double UnitPrice, String ManufacturerName) {


    The constructor is always named after the class it's in, NOT that class's superclass.

    Furthermore, you must call the superclass's constructor in a class's constructor (in this case, call Cameras's constructor in Manufacturer's constructor). These means that each of the five parameters passed to Cameras's constructor must also be passed to Manufacturer's constructor, and the first line of Manufacturer's constructor must look something like this:

    super(item,product,units,price,serial);

    Finally, you cannot refer to private members of a class in its subclass. In order to do that, you must define their visibility as "protected" rather than "private".
    Fubarable likes this.

  3. #3
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    this is my code i add some more and i got it to 8 errors now and i just cant find them i am so sorry i am new to all of this..

    public class Cameras{

    private int itemNumber;

    private String productName;

    private int unitsInStock;

    private double price;



    public Cameras() {

    }



    public Cameras(int itemNumber, String productName, int unitsInStock,

    double price) {

    this.itemNumber = itemNumber;

    this.productName = productName;

    this.unitsInStock = unitsInStock;

    this.price = price;

    }


    public double calculateInventory() {

    return this.unitsInStock * this.price;

    }



    public int getItemNumber() {

    return itemNumber;

    }

    public String getProductName() {

    return productName;

    }

    public int getUnitsInStock() {

    return unitsInStock;

    }

    public double getPrice() {

    return price;

    }


    public void setItemNumber(int itemNumber) {

    this.itemNumber = itemNumber;

    }

    public void setName(String productName) {

    this.productName = productName;

    }




    public void setUnitsInStock(int unitsInStock) {

    this.unitsInStock = unitsInStock;

    }


    public void setPrice(double price) {

    this.price = price;

    }

    }


    class Manufacturer extends Cameras {
    private String manufacturerName;



    public Manufacturer(int itemNumber, String productName, int unitsInStock,double price, String ManufacturerName); { [ missing body or declare abstract]
    ^
    super(itemNumber, productName, unitsInStock, price);[call to super must be first statement in constructor]
    ^
    this.ManufacturerName = ManufacturerName; [can not find symbol]
    ^ ^
    }



    public double calculateRestockFee() {
    return super.calculateInventory() * .05;
    }

    public double calculateInventory() { [unitInstock has private access in Cameras]
    return this.unitsInStock * this.price;
    ^ ^
    }



    public String getManufacturerName(){ [can not find symbol]
    return ManufacturerName;
    ^
    }



    public void setManufacturerName(String ManufacturerName){ [can not find symbol]
    this.ManufacturerName = ManufacturerName;
    ^
    }
    }
    Last edited by MikeJ39; 10-11-2011 at 03:38 PM. Reason: adding the errors in

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I need help i have 8 errors can someone pleasehelp me

    You're not telling us what errors you're seeing which is making it hard to help you. Also you'll want to edit your posts above and add code tags so that your code is readable. To do this, add the tag [code] above your code block, and the tag [/code] below your code block:

  5. #5
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    OK i got all the errors fixed all but one now and that is in public static void main(String[] args);
    ^
    now what do i do?

  6. #6
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    tell us wich error you get....

    that'll help a lot

  7. #7
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    ok i got the first done now if you look at the last post i have the errors maked with ^ but i got the body one fix now i need to fix the rest

  8. #8
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    we mean that you should show us the error that you get when you run the program...

    prob an exception... like a nullPointerException,...

    tell us wich one it is, it'll make it easier for us to search where the problem might be..

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default Re: I need help i have 8 errors can someone pleasehelp me

    Quote Originally Posted by liluma View Post
    we mean that you should show us the error that you get when you run the program...

    prob an exception... like a nullPointerException,...

    tell us wich one it is, it'll make it easier for us to search where the problem might be..
    No, at least one of them is a compilation errror; when a compiler refuses to compile a .java file it isn't possible to run it so all of the errors are compile time errors.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    ok this is my code: the errors i am getting is line 105 missing body, or declare abstract [public Manufacturer(int itemNumber, String productName, int unitsInStock,double price, String ManufacturerName); {
    ^
    and then on line 107 [ Error call to super must be first statement in constructor[ super(itemNumber, productName, unitsInStock, price);
    ^
    then on line 119 their are 2 errors public double calculateInventory() {
    return this.unitsInStock * this.price;
    ^ ^

    Java Code:
    class Cameras{
    
    public static void main(String[] args){
    }
    
    private int itemNumber;
    
    private String productName;
    
    private int unitsInStock;
    
    private double price;
    
     
    
    public Cameras() {
    
    }
    
    
    
    public Cameras(int itemNumber, String productName, int unitsInStock,
    
    double price) {
    
    this.itemNumber = itemNumber;
    
    this.productName = productName;
    
    this.unitsInStock = unitsInStock;
    
    this.price = price;
    
    }
             
    
    public double calculateInventory() {
    
    return this.unitsInStock * this.price;
    
    }
    
    
    
    public int getItemNumber() {
    
    return itemNumber;
    
    }
    
    public String getProductName() {
    
    return productName;
    
    }
    
    public int getUnitsInStock() {
    
    return unitsInStock;
    
    }
    
    public double getPrice() {
    
    return price;
    
    }
    
    
    public void setItemNumber(int itemNumber) {
    
    this.itemNumber = itemNumber;
    
    }
    
    public void setName(String productName) {
    
    this.productName = productName;
    
    }
    
     
    
    
    public void setUnitsInStock(int unitsInStock) {
    
    this.unitsInStock = unitsInStock;
    
    }
    
    
    public void setPrice(double price) {
    
    this.price = price;
    
    }
    
    }
    
    class  Manufacturer extends Cameras {
    private String manufacturerName;
    
    
    
    public Manufacturer(int itemNumber, String productName, int unitsInStock,double price, String ManufacturerName); {
                                                                                            
    super(itemNumber, productName, unitsInStock, price);
         this.manufacturerName = manufacturerName;
        
    }
    
    
    
    public double calculateRestockFee()  {
        return super.calculateInventory() * .05;
    }
    
    public double calculateInventory() {
        return this.unitsInStock * this.price;
    	                             
    }
    
    
    public String getManufacturerName(){
        return manufacturerName;
    
    }
    
    
    
    public void setManufacturerName(String ManufacturerName){
       this.manufacturerName = manufacturerName; 
    }
       }
    Last edited by Fubarable; 10-11-2011 at 07:16 PM. Reason: code tags added

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I need help i have 8 errors can someone pleasehelp me

    Code tags were added to your post above, but it's still difficult to read as you've posted unformatted or poorly formatted code.

  12. #12
    DiamondSoul is offline Member
    Join Date
    Oct 2011
    Posts
    83
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    You have a superfluous semicolon in line 105. Remove that and the first two errors should be fixed.

    For the other error, the following method:

    Java Code:
    public double calculateInventory() {
        return this.unitsInStock * this.price;
                                      
    }
    should go in the Cameras class, not the Manufacturer class. This is because unitsInStock and price are declared as private in the Cameras class, and are not visible in Manufacturer. Also, the two "this." in that method are unnecessary, though they won't break the program. Same with the "super." in line 115.

  13. #13
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    ok i am so lost with this all did you make changes to the code i put in?

  14. #14
    DiamondSoul is offline Member
    Join Date
    Oct 2011
    Posts
    83
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    Fubarable did not make any changes to the code itself, he just added [code] tags around it, making it slightly more readable. Apply the changes I mentioned in my previous post and your program should work (at least, it should compile successfully).

  15. #15
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    ok i got that fixed and now i have another code for inventory. could you check it out for me please because i am getting 10 errors when i try to compile....

    Most of the errors are the same in each line as follows:

    error: cannot find symbol
    products[0] = new manufacturer(500, "PowerShot", 10, 800, "Canon");
    ------------------^
    __________________________________________________ _____________________

    The other error I am getting on one line is as follows:

    error: incompatible types
    Manufacturer manufacturer = products[i];
    ------------------------------------^

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default Re: I need help i have 8 errors can someone pleasehelp me

    If you'd used those [code] ... [/code] tags those little carets would've ended up where they belong; it was already suggested to you to do so. Tip: read what the compiler had to say; the folks who implemented that compiler did their best to make those error messages as clear as possible.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  17. #17
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    ok Jos i have a new code and i am getting 11 errors on it can you please help me with this i tried everything

    error: cannot find symbol
    Java Code:
    Supplier[] products = new Supplier[5];
    ^

  18. #18
    DiamondSoul is offline Member
    Join Date
    Oct 2011
    Posts
    83
    Rep Power
    0

    Default Re: I need help i have 8 errors can someone pleasehelp me

    Quote Originally Posted by MikeJ39 View Post
    error: cannot find symbol
    products[0] = new manufacturer(500, "PowerShot", 10, 800, "Canon");
    ------------------^
    Manufacturer must be capitalized.

  19. #19
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I need help i have 8 errors can someone pleasehelp me

    Quote Originally Posted by MikeJ39 View Post
    ok Jos i have a new code and i am getting 11 errors on it can you please help me with this i tried everything

    error: cannot find symbol
    Java Code:
    Supplier[] products = new Supplier[5];
    ^
    So you know for a fact that you've created a Supplier class? I'm asking because I don't see it here. Again, believe what the error message is telling you as it's usually on the money or if not, close to it.

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  2. errors
    By santosh chauhan in forum New To Java
    Replies: 5
    Last Post: 07-26-2010, 07:59 PM
  3. Errors?
    By Jamison5213 in forum New To Java
    Replies: 4
    Last Post: 12-30-2009, 12:14 AM
  4. getting errors
    By ravikumar in forum Threads and Synchronization
    Replies: 3
    Last Post: 08-23-2009, 02:50 PM
  5. Replies: 3
    Last Post: 03-08-2009, 01:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •