Menu

[Solved] Part 1 Design Pet Object Pet Created Language Argument String Stomach Represented Array Pe Q37185468

JavaScript Homework: Thank you in advance!

Part 1 Design a Pet object. A Pet is created with a language argument string and a stomach represented by an array. The Pet sPart 2 Create an object, Dog, that implements the Pet interface and takes the same argument language. Dogs eat the same way aPart 3 Implement at least two test cases to make sure your Dog object is correctly implementing the Pet interface with its ow

Part 1 Design a Pet object. A Pet is created with a language argument string and a stomach represented by an array. The Pet should support functions: eatand speak). Use the prototype property to define your object’s interface. eat food) will store the passed argument into its stomach and return what it has eaten thus far speak(sentence) will simply return the passed in phrase. function Pet (language) ( r create stonach set language takes a food item STRING and returns everything eaten so far ARRAY Pet.prototype.eat(food item)t // ..·coplete takes in a sentence STRING and returns the passed in sentence STRING with no change Pet.prototype.speak(sentence)( complete Part 2 Create an object, Dog, that implements the Pet interface and takes the same argument language. Dogs eat the same way all pets do. Dogs speak differently. Dogs replace each word in a sentence with its only known language, “woof”. For example, if the sentence is “I like bones”, the speak0 method will turn it into For BONUS points (5 points): ° Implement a second pet of your choosing that implements the same Pet interface. You may be creative with what eat() and speak() will do differently for your new pet. Part 3 Implement at least two test cases to make sure your Dog object is correctly implementing the Pet interface with its own override functions (if applicable). You may use the assert) method we defined in the lecture notes page of this module or define your own assert0. The test code can live in the same file and should create an instance of a Dog object in order to test. Show transcribed image text Part 1 Design a Pet object. A Pet is created with a language argument string and a stomach represented by an array. The Pet should support functions: eatand speak). Use the prototype property to define your object’s interface. eat food) will store the passed argument into its stomach and return what it has eaten thus far speak(sentence) will simply return the passed in phrase. function Pet (language) ( r create stonach set language takes a food item STRING and returns everything eaten so far ARRAY Pet.prototype.eat(food item)t // ..·coplete takes in a sentence STRING and returns the passed in sentence STRING with no change Pet.prototype.speak(sentence)( complete
Part 2 Create an object, Dog, that implements the Pet interface and takes the same argument language. Dogs eat the same way all pets do. Dogs speak differently. Dogs replace each word in a sentence with its only known language, “woof”. For example, if the sentence is “I like bones”, the speak0 method will turn it into For BONUS points (5 points): ° Implement a second pet of your choosing that implements the same Pet interface. You may be creative with what eat() and speak() will do differently for your new pet.
Part 3 Implement at least two test cases to make sure your Dog object is correctly implementing the Pet interface with its own override functions (if applicable). You may use the assert) method we defined in the lecture notes page of this module or define your own assert0. The test code can live in the same file and should create an instance of a Dog object in order to test.

Expert Answer


Answer to Part 1 Design a Pet object. A Pet is created with a language argument string and a stomach represented by an array. The … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *