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 8678671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:46:56+00:00 2026-06-12T20:46:56+00:00

I’m in Java programming (I’m on my first year at uni). I’ve got an

  • 0

I’m in Java programming (I’m on my first year at uni). I’ve got an assessment where I need to create 3 classes. In one of the classes I need to have a constructor with a parameter of String type. It needs to allow me to create a new object (pack of crisps) in which I am supposed to state the flavour of it.

Whenever I try to create the object I get the textbox where I can type in the flavour of crisps but when I press ok I get the error (e.g. ) Cannot find symbol – variable bbq.

I had a similar example before which took int type and it worked fine.

When I compare my code with other – working examples – I really can’t find what I am doing wrong.

I would appreciate if someone could advise.

public class PackOfCrisps
{
private String flavour;
private int numOfCrisps;
private boolean open;

/**
 * Constructor for a single pack of crisps.
 */
public PackOfCrisps(String newFlavour)
{
    flavour = newFlavour;
    numOfCrisps = 10;
    open = true;
}

/**
 * Return whether the packet is empty.
 */
public boolean isEmpty() 
{
    if (numOfCrisps == 0) 
    {
        return true;
    } else
        return false;
}

/**
 * Return whether the packet is closed.
 */
public boolean isClosed() 
{
    return open;
}

/**
 * Change the boolean value of 'open' variable.
 */
public void open()
{
    open = !open;
}

/**
 * Return the flavour of the packet of crisps.
 */
public String getFlavour()
{
    return flavour;
}

/**
 * Decrease the number of crisps by 1 until the packet is empty.
 */
public void eatCrisps()
{
    if (open) 
    {
        System.out.println("Need to open the packet first!");
    } else if ((numOfCrisps > 1) && (numOfCrisps <= 10)){
        numOfCrisps = numOfCrisps - 1;

        System.out.println(numOfCrisps);
    } else {
        System.out.println("The packet is empty!");
    }
}

}

UPDATE

I’m using BlueJ for my programming.
I would imagine that it must be something pretty ‘simple’ that I am missing because it is my 3rd week at university and we literally started from scratch.

UPDATE 2

I’m sorry if my answers don’t always describe everything 100% but because I’m still a noob at programming I am bound to miss some info. I think this would be the answer to your question: because I use BlueJ, when I have a class in compiler (I believe displayed in a class diagram) I just right-click it and choose “new PackOfCrisps(String newFlavour)” and then I get the box in which I can type in crisps flavour but when I press ‘Ok’ I get error message.

his is all I get/see

I tried to play with other options to see if I can get any more info but with no success.

  • 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-12T20:46:58+00:00Added an answer on June 12, 2026 at 8:46 pm

    Note: This was a comment above, but I am “elevating” it to an answer.

    Based on your Update 2 and the screenshots above here is my guess.

    The text box that BlueJ pops up probably allows you to type in a variable name or a string. If you want it to be a string then type in “BBQ” with the quotes.

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I

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.