Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8857273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:33:02+00:00 2026-06-14T14:33:02+00:00

I keep getting an error when Im compiling my code. I believe my logic

  • 0

I keep getting an error when Im compiling my code. I believe my logic is fine and everything but I must have made a error while creating the BushelBasket class. I was told not to alter the main method in any way by my instructor. Thanks for any help in advance!

public class AppleOrchard
{
    public static void main(String [] args)
    {
        System.out.println("Rick...");
        BushelBasket rick = new BushelBasket(0);
        rick.print();
        rick.pick(11);
        rick.pick(22);
        rick.print();
        rick.eat(4);
        rick.print();
        rick.spill();
        rick.print();

        System.out.println("Newt...");
        BushelBasket newt = new BushelBasket(100);
        newt.print();

        System.out.println( newt.isEmpty() );
        System.out.println( newt.isFull() );
        System.out.println( newt.getApples() );
        System.out.println( newt.roomLeftInBasket() );

        System.out.println("Michele...");
        BushelBasket michele = new BushelBasket(0);
        System.out.println( michele.isEmpty() );
        System.out.println( michele.isFull() );
        michele.pick(25);
        System.out.println( michele.isEmpty() );
        System.out.println( michele.isFull() );
        michele.pick(100);
        System.out.println( michele.isEmpty() );
        System.out.println( michele.isFull() );

        System.out.println("Herman...");
        BushelBasket herman = new BushelBasket(-5);  // should default to 0
        herman.print();

        System.out.println("Jon...");
        BushelBasket jon = new BushelBasket(300);  // should default to 125
        jon.print();

        System.out.println("Ron...");
        BushelBasket ron = new BushelBasket(20);  // starts with 20
        ron.print();
        ron.eat(50);  // can only eat down to zero apples
        ron.print();  // should see zero apples
        ron.eat(10);  // back to 10
        ron.pick(1000);  // basket can only hold 125 apples
        ron.print();  // should print 125

        System.out.println("Gary...");
        BushelBasket gary = new BushelBasket();  // should default to 0
        gary.print();
    }
}
class BushelBasket()
{
        public void spill()
        {
            apples = 0;
        }

        public void pick(int x)
        {
            apples = apples + x;
        }

        public void eat(int x)
        {
            apples = apples - x;
        }

        public int getApples()
        {
            return apples;  
        }

        public void print()
        {
            int x = getApples();
            System.out.println("This bushel basket has " + x + " apples in it.");
        }

        public boolean isEmpty()
        {
            int emtpy = 0;

            if (apples <= emtpy)
            {   
                return true;
            }

            else 
            {
                return false;
            }
        }

        public boolean isFull()
        {
            int full = 125;

            if (apples >= full)
            {   
                return true;
            }

            else 
            {
                return false;
            }

        }

        public boolean roomLeftInBasket()
        {
            int full = 125;

            if (apples < full)
            {   
                return true;
            }

            else 
            {
                return false;
            }

        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:33:03+00:00Added an answer on June 14, 2026 at 2:33 pm

    Your java app can’t compile.

    you need to declare a variable apples in BushelBasket

    and you have missing constructor that assigns apples

    public BushelBasket(int apples)
    {
       this.apples = apples;
    
    }
    

    BTW,

    Instead of

    class BushelBasket()
    

    it should be

    class BushelBasket
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to code some stuff for a game but I keep getting error
With the following code, I keep getting error C2535 when I compile. It's complaining
I keep getting this error and have no idea why. I googled and scanned
I'm trying to enter http://localhost/phpmyadmin/index.php but I keep getting : Error MySQL said: #1130
I am compiling my code with g++ -g and I am getting the error
I'm modifying inherited code and keep getting a weird cannot find symbol error which
I want to add this awk command on my script but keep getting error.
I keep getting this syntax error but can't find anything wrong with it when
I'm trying to install a package that uses global-linum-mode and keep getting: error Autoloading
Keep getting this error after inserting a subdatasheet into a query and trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.