1.Create a UML for an Animal - decide the data type and access level (private, public, protected) for each property and method · Properties · name · sizeInKg · Methods (you will need to supply the...

1 answer below »
see attached doc


1.Create a UML for an Animal -  decide the data type and access level (private, public, protected) for each property and method · Properties · name · sizeInKg · Methods (you will need to supply the input parameters, types, and return type) · Animal() (constructor) · Animal(name, sizeInKg) · setName() // if necessary · getName() · setSizeInKg()   //  if necessary · getSizeInKg() · toString() · eat()  · makeNoise() 2.Using the UML you created for Animal, create the Kotlin code for the Animal class. Then add a main function to your Animal.kt file that instantiates an Animal named "Fred" weighing 237, and eats and makes noise, and calls the toString method.  Set Fred's weight to 200, and call the toString method again. Create another Animal named "Roket", weighing 5, eats, makes noise, and calls the toString method. 3.Modify your Animal class (Module 5 Homework Assignment #2) so that other classes can inherit from it.  Create a Dog class, that inherits from Animal.  Dog should override the makeNoise method so that when a Dog makes noise the noise is "WOOF" if the size is > 50 and "YIPYIP" if the size is <= 50.  dog should have a member variable breed which is a string.  create a uml if it helps. create a cat class, that inherits from animal.  cat should override the makenoise method so that when a cat makes noise the noise is "mew".  cat should have a member variable breed which is a string. create a uml if it helps. in a main() function, create an animal, a cat and two dogs (one large, and one small).  create a function feed modeled after the function feed in the textbook p. 274: fun feed(animaltofeed:anima) { // feed any animal here } in the feed function, the animal should eat, and should also makenoise.  output from your program might look like this (fred is an animal, coco is a dog weighing 30lbs, and dora is a cat): fred eats hay fred makes noise coco eats kibble yipyip dora eats fish mew don't forget to put your name in all of your files, and comment your code. 50. ="" dog="" should="" have="" a="" member="" variable="" breed="" which="" is="" a="" string. ="" create="" a="" uml="" if="" it="" helps.="" create="" a="" cat="" class,="" that="" inherits="" from="" animal. ="" cat="" should="" override="" the="" makenoise="" method="" so="" that="" when="" a="" cat="" makes="" noise="" the="" noise="" is="" "mew". ="" cat="" should="" have="" a="" member="" variable="" breed="" which="" is="" a="" string.="" create="" a="" uml="" if="" it="" helps.="" in="" a="" main()="" function,="" create="" an="" animal,="" a="" cat="" and="" two="" dogs="" (one="" large,="" and="" one="" small). ="" create="" a="" function="" feed="" modeled="" after="" the="" function="" feed="" in="" the="" textbook="" p.="" 274:="" fun="" feed(animaltofeed:anima)="" {="" feed="" any="" animal="" here="" }="" in="" the="" feed="" function,="" the="" animal="" should="" eat,="" and="" should="" also="" makenoise. ="" output="" from="" your="" program="" might="" look="" like="" this="" (fred="" is="" an="" animal,="" coco="" is="" a="" dog="" weighing="" 30lbs,="" and="" dora="" is="" a="" cat):="" fred="" eats="" hay="" fred="" makes="" noise="" coco="" eats="" kibble="" yipyip="" dora="" eats="" fish="" mew="" don't="" forget="" to="" put="" your="" name="" in="" all="" of="" your="" files,="" and="" comment="" your="">
Answered 1 days AfterOct 15, 2021

Answer To: 1.Create a UML for an Animal - decide the data type and access level (private, public, protected)...

Swapnil answered on Oct 17 2021
124 Votes
93794/First.docx
        1
        Data members:
· name - Private, String
· sizeInKg - Private, float
Membe
r functions:
· Animal() - Public, void
· Animal(name, sizeInKg) - Public, void
· setName() - Public, void
· getName() - Public, String
· setSizeInKg() - Public, void
· getSizeInKg() - Public, String
· toString() - Public, String
· eat() - Public, void
· makeNoise() - Public, void
UML Diagram:Animal
Name: String
sizeInKg: Int
Animal(): void
Animal(String, int): void
setName(): void
getName():String
setSizeInKg(): void
getSizeInKg():String
toString():String
eat(): void
makeNoise(): void
93794/Second.kt
class Animal(private var n: String, private var w: Int)
{
fun setW(v:Int)
{
w=v
}
fun eat()
{
println("$n is eating.")
}
fun noise()
{
println("$n is making noise")
}
override fun toString(): String
{
return...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here