Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

faculty.harford.edu Create a project using the usual naming convention and add a class with a main and also the class Buny given above. When you

image text in transcribed
image text in transcribed
faculty.harford.edu Create a project using the usual naming convention and add a class with a main and also the class Buny given above. When you make methods in the class with main, add the keywond static, just as main uses it. Part A Add a method makeBools which takes an int sine and returns an amay of booleans. In the method, create an array of booleans whose length is sine. Make every third element of the array true. Add a method mashUp which takes an amay of S rings and returns a String thal consists of all those sri gs concatenated together with paces between, sof given the amay (Hello", "world.. "this",-is your message. mashUp would return "Hello world this is your message 2 Add a method makeBunnies, which takes as parameter an aay of Strings, and returms an array of Bunnys In makeBunnies, create an array of Bunnys the same size as the array of strings In a loop, aill the array wih Burnys, Give each Bunny as its name the string in the same position in the string aray. So if "Bob' is at index 3 in the string array, the Bunny a index 3 in bunnyList should be named Bob. e Also give cach Bunry a carrotcount based on the position in the array, so that the Bunny a array index 0 has carroecount 0, the Bunny at array index 1 has carroccount 1, etc. hint: the Bunny class has a parumeterized constructor that takes name and carrotcount) Return the aray of Bunnys created In main, make and print an array of at leas S Bunnys using the special amay initialtatoa io aene the mayofStrings you give to nateBannis Part B dd a new class Bunny Farmer which has an instance variable to hold the farmer's name and also an instance variable butch, which is an array of Bunnys. Also add an instance variable firstEmptyIndex, an int, to keep track of the first empty spot in hutch. Make accessors and mutadoes for hutch and frstEmpty ndex, but mark them peivate we don't want these accessible from outside the class. la the defaalt conseructor for BuncyFarmer, set up the aray butch with space for 10 Bunmys. In this case there are no actual Bunnys yet, so firstEmptylndex is o. Add a method addBunnyf which takes a Bunny as parameter. Check firstEmptyIndex to see if there is still space in hutch. If so, put the given Bunny in the first empty spot in the aray and increment firstEmpty ndex. If we are out of space, do mothing. In the toString for this class,return String with the farmer's name an the top and then a numbered list of the Bunnys (using the toSering from Bunny). You should only go up to firstEimptylndes, since all the spotes beyond that will be empry. So something like: unry Butch anay an (10 earrota) unay r.Bamington 11 carrots) faculty.harford.edu Create a project using the usual naming convention and add a class with a main and also the class Buny given above. When you make methods in the class with main, add the keywond static, just as main uses it. Part A Add a method makeBools which takes an int sine and returns an amay of booleans. In the method, create an array of booleans whose length is sine. Make every third element of the array true. Add a method mashUp which takes an amay of S rings and returns a String thal consists of all those sri gs concatenated together with paces between, sof given the amay (Hello", "world.. "this",-is your message. mashUp would return "Hello world this is your message 2 Add a method makeBunnies, which takes as parameter an aay of Strings, and returms an array of Bunnys In makeBunnies, create an array of Bunnys the same size as the array of strings In a loop, aill the array wih Burnys, Give each Bunny as its name the string in the same position in the string aray. So if "Bob' is at index 3 in the string array, the Bunny a index 3 in bunnyList should be named Bob. e Also give cach Bunry a carrotcount based on the position in the array, so that the Bunny a array index 0 has carroecount 0, the Bunny at array index 1 has carroccount 1, etc. hint: the Bunny class has a parumeterized constructor that takes name and carrotcount) Return the aray of Bunnys created In main, make and print an array of at leas S Bunnys using the special amay initialtatoa io aene the mayofStrings you give to nateBannis Part B dd a new class Bunny Farmer which has an instance variable to hold the farmer's name and also an instance variable butch, which is an array of Bunnys. Also add an instance variable firstEmptyIndex, an int, to keep track of the first empty spot in hutch. Make accessors and mutadoes for hutch and frstEmpty ndex, but mark them peivate we don't want these accessible from outside the class. la the defaalt conseructor for BuncyFarmer, set up the aray butch with space for 10 Bunmys. In this case there are no actual Bunnys yet, so firstEmptylndex is o. Add a method addBunnyf which takes a Bunny as parameter. Check firstEmptyIndex to see if there is still space in hutch. If so, put the given Bunny in the first empty spot in the aray and increment firstEmpty ndex. If we are out of space, do mothing. In the toString for this class,return String with the farmer's name an the top and then a numbered list of the Bunnys (using the toSering from Bunny). You should only go up to firstEimptylndes, since all the spotes beyond that will be empry. So something like: unry Butch anay an (10 earrota) unay r.Bamington 11 carrots)

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

ISBN: 0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Compare the current team to the ideal team.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago