Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Copy the Bug class from Lab4. You do not need to make an alterations to it. ( In bold below ) b. Create a

a. Copy the Bug class from Lab4. You do not need to make an alterations to it. (In bold below)

b. Create a tester class named BugTester

c. Create a main method

d. Create a Bug object with 10 as the argument

e. In a loop, breed the bugs 4 times.

f. In a loop, spray the bugs 4 times.

g. Print the result.

public class BugTester { // instance variables - replace the example below with your own private int x;

/** * Constructor for objects of class BugTester */ public BugTester() { // initialise instance variables x = 0; }

/** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public int sampleMethod(int y) { // put your code here return x + y; } }

Breed and Spray came from this code: (In Italics)

public class Bug { private int totalBugs; public Bug() { totalBugs = 0; } public Bug(int initialBugs) { totalBugs = initialBugs; } public void breedBugs() { totalBugs = 2 * totalBugs; } public void sprayBugs() { totalBugs = (int)(totalBugs * .75); } public int returnTotal() { return totalBugs; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago