Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By jim829

Thread: Help with program

  1. #1
    BookOfEliX is offline Member
    Join Date
    Feb 2015
    Posts
    20
    Rep Power
    0

    Default Help with program

    Hey guys I am trying to practice some OOP and I keep on getting this error stating "cannot find symbol"

    Java Code:
    public class Triangle{
       public static void main(String[] args){
          TriangleFeatures A = new TriangleFeatures(2.0);
          //base.getBase(2.0);
          System.out.print("The base of Triangle A is: " + base.getBase() + ".");
            
       }
    }



    Java Code:
    class TriangleFeatures{
       private double base;
       
       TriangleFeatures(){
          base = 0; 
       }
       
       TriangleFeatures(double newBase){
          this.base = newBase;
       }
       
       public double getBase(){
          return base;
       }
       
       public void setBase(double x){
          this.base = base;
       }
    
    
    
    }




    can someone help me? I receive the error when I try to print out the base of the triangle. (base.getBase())
    Last edited by BookOfEliX; 04-13-2015 at 02:08 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help with program

    Try A.getBase(). And instance fields and local variables should be lower case by convention.

    Regards,
    Jim
    BookOfEliX likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    BookOfEliX is offline Member
    Join Date
    Feb 2015
    Posts
    20
    Rep Power
    0

    Default Re: Help with program

    Thanks Jim, I am thankful for the help and advice.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Help with program

    Quote Originally Posted by BookOfEliX View Post
    Help with program
    Please go through the Forum Rules, especially the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 6
    Last Post: 12-15-2013, 06:40 AM
  2. Replies: 4
    Last Post: 11-21-2012, 01:19 PM
  3. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  4. Replies: 13
    Last Post: 03-22-2011, 06:49 AM
  5. Replies: 0
    Last Post: 04-04-2008, 02:40 PM

Tags for this Thread

Posting Permissions

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