Question: For Kotlin language For this assignment, you should make an entirely new project and immediately create a new BirdCage class (no need to create a

For Kotlin language

For this assignment, you should make an entirely new project and immediately create a new BirdCage class (no need to create a separate package, as is covered in the tutorial, you can just put your class file directly in the src folder). Imagine that your bird cage is cylindrical, with bars extending regularly from the base of the cage to a point above the center fo the base; like this one. Your BirdCage class should include:

  • Initialization parameters for height, radius, and barDensity (use types you think appropriate)
  • An init to print a 'Constructing Bird Cage' string
  • Methods for:
    • printSize (in a form similar to the tutorial)
    • checkFit (a function that checks to see if a given bird will fit into the cage without escaping - pass checkFit an integer value and as long as it is greater than the space between the bars we say the bird will fit. i.e. checkFit(birdSize: Int): Boolean)
  • Property getters and setters for:
    • numberOfBars (equal to the barDensity / circumference of the cage floor - the setter should set the barDensity)

Please check that your completed class is working by creating a main.kt file and creating a new BirdCage instance!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!