Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to changed the access specifiers on your Burrito class to allow the class va

ID: 3714489 • Letter: H

Question

How to changed the access specifiers on your Burrito class
to allow the class variables to be changed inside your BurritoSupreme.

import java.io.*;

import java.lang.*;

import java.util.Scanner;

public class BurritoSupreme extends Burrito

{

       // inherit from Burrito: beans, beef, cheese, salsa

   int sourCreame;

   int olives;

   BurritoSupreme()

   {

       super();

       System.out.println("Making a default BurritoSupreme");

       sourCreame = 1;

       olives = 1;

   }

   BurritoSupreme(int beans, int beef, int cheese, int salsa, int sourCreame, int olives)

   {

       super(beans, beef, cheese, salsa);

       System.out.println("Making a custom BurritoSupreme");

       this.sourCreame = sourCreame;

       this.olives = olives;

   }

   void print_order()

   {

       System.out.println("No Name's burrito will be made out of: ");

       System.out.println(beans + " ounce(s) of beans");

       System.out.println(beef + " ounce(s) of beef");

       System.out.println(cheese + " ounce(s) of cheese");

       System.out.println(salsa + " ounce(s) of salsa");

       System.out.println(sourCreame + " ounce(s) of sour cream");

       System.out.println(olives + " ounce(s) of olives");

   }

   int weight()

   {

       return beans + beef + cheese + salsa + sourCreame + olives;

   }

   void gutBuster()

   {

       System.out.println("Invoking the Gut Buster Special!!!");

beans = beans * 2;

       beef = beef * 2;

       cheese = cheese * 2;

       salsa = salsa * 2;

       sourCreame = sourCreame * 2;

       olives = olives * 2;

   }

}



Lab8.java SOURCE: ============================

import java.io.*;

import java.lang.*;

import java.util.Scanner;

public class Lab8

{

   public static void main (String[] args)

   {

       Burrito b = new Burrito();

       BurritoSupreme b0 = new BurritoSupreme(); // will access BurritoSupreme.java

       b0.print_order();

       System.out.println("The burrito weighs " + b0.weight() + " ounces");

       b0.gutBuster();

       b0.print_order();

       System.out.println("The burrito weighs " + b0.weight() + " ounces");

       Scanner reader = new Scanner(System.in);

       int beans, beef, cheese, salsa, sourCreame, olives;

       System.out.println(" Enter number of beans :");

       beans = reader.nextInt();

       System.out.println("Enter number of beef :");

       beef=reader.nextInt();

       System.out.println("Enter number of cheese :");

       cheese = reader.nextInt();

       System.out.println("Enter number of salsa :");

       salsa = reader.nextInt();

       System.out.println("Enter number of sour creame :");

       sourCreame = reader.nextInt();

       System.out.println("Enter number of olives :");

       olives = reader.nextInt();

       BurritoSupreme b1 = new BurritoSupreme(beans,beef,cheese,salsa,sourCreame,olives);

       b1.print_order();

       System.out.println("The burrito weighs " + b1.weight() + " ounces");

       b1.gutBuster();

       b1.print_order();

       System.out.println("The burrito weighs " + b1.weight() + " ounces");

}

}

==========================================================

OUTPUT: ==================================================

Making a default BurritoSupreme

No Name's burrito will be made out of:

2 ounce(s) of beans

1 ounce(s) of beef

1 ounce(s) of cheese

1 ounce(s) of salsa

1 ounce(s) of sour cream

1 ounce(s) of olives

The burrito weighs 7 ounces

Invoking the Gut Buster Special!!!

No Name's burrito will be made out of:

4 ounce(s) of beans

2 ounce(s) of beef

2 ounce(s) of cheese

2 ounce(s) of salsa

2 ounce(s) of sour cream

2 ounce(s) of olives

The burrito weighs 14 ounces

Enter number of beans :

1

Enter number of beef :

2

Enter number of cheese :

3

Enter number of salsa :

4

Enter number of sour creame :

5

Enter number of olives :

6

Making a custom BurritoSupreme

No Name's burrito will be made out of:

1 ounce(s) of beans

2 ounce(s) of beef

3 ounce(s) of cheese

4 ounce(s) of salsa

5 ounce(s) of sour cream

6 ounce(s) of olives

The burrito weighs 21 ounces

Invoking the Gut Buster Special!!!

No Name's burrito will be made out of:

2 ounce(s) of beans

4 ounce(s) of beef

6 ounce(s) of cheese

8 ounce(s) of salsa

10 ounce(s) of sour cream

12 ounce(s) of olives

The burrito weighs 42 ounces

DUE DATE: apr 23 7:00am ========================================

total 40

drwxrwxr-x. 2 htoo htoo 4096 Apr 23 06:58 .

drwx------. 11 htoo htoo 4096 Apr 22 23:11 ..

-rw-rw-r--. 1 htoo htoo 430 Apr 22 23:59 Burrito.class

-rw-rw-r--. 1 htoo htoo 427 Apr 22 23:42 Burrito.java

-rw-rw-r--. 1 htoo htoo 1589 Apr 22 23:59 BurritoSupreme.class

-rw-rw-r--. 1 htoo htoo 1533 Apr 22 23:59 BurritoSupreme.java

-rw-rw-r--. 1 htoo htoo 2443 Apr 22 22:58 Lab8

-rw-rw-r--. 1 htoo htoo 1442 Apr 22 23:59 Lab8.class

-rw-rw-r--. 1 htoo htoo 1471 Apr 22 23:44 Lab8.java

-rw-r--r--. 1 root root 1757 Apr 23 06:58 README.MCU

==========================================================


Looks good, except you changed the access specifiers on your Burrito class

to allow the class variables to be changed inside your BurritoSupreme. -30pts

Grade: 70

unce(s) of sour cream

12 ounce(s) of olives

The burrito weighs 42 ounces

DUE DATE: apr 23 7:00am ========================================

total 40

drwxrwxr-x. 2 htoo htoo 4096 Apr 23 06:58 .

drwx------. 11 htoo htoo 4096 Apr 22 23:11 ..

-rw-rw-r--. 1 htoo htoo 430 Apr 22 23:59 Burrito.class

-rw-rw-r--. 1 htoo htoo 427 Apr 22 23:42 Burrito.java

-rw-rw-r--. 1 htoo htoo 1589 Apr 22 23:59 BurritoSupreme.class

-rw-rw-r--. 1 htoo htoo 1533 Apr 22 23:59 BurritoSupreme.java

-rw-rw-r--. 1 htoo htoo 2443 Apr 22 22:58 Lab8

-rw-rw-r--. 1 htoo htoo 1442 Apr 22 23:59 Lab8.class

-rw-rw-r--. 1 htoo htoo 1471 Apr 22 23:44 Lab8.java

-rw-r--r--. 1 root root 1757 Apr 23 06:58 README.MCU

==========================================================


Looks good, except you changed the access specifiers on your Burrito class

to allow the class variables to be changed inside your BurritoSupreme. -30pts

Grade: 70

Explanation / Answer

I) Do not change the access specifiers of your Burrito class

1) If it was public keep it public
2) If it was protected keep it protected
3) It cant be private as we are inherting the class

II) Your BurritoSupreme Class


Make sourCreame and olives as PRIVATE data members like

private int sourCreame;

private int olives;


Try these two things and let me know , I will help if things are not resolved. Comment and I will respond

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote