Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Classes Methods and Properties Create Following classes and properties Hamster attributes: owner - string, initially set as an empty string name - string, set the

Classes Methods and Properties Create Following classes and properties Hamster attributes: owner - string, initially set as an empty string name - string, set the name from parameter in constructor method price - integer, set as 15 methods: wheelRun() - log "squeak squeak" eatFood() - log "nibble nibble" getPrice() - return the price ------------------------------------------------------- Person attributes: name - set name from parameter in constructor method age - initially 0 height - initially 0 weight - initially 0 mood - integer starting at 0 initially hamsters - empty array initially bankAccount - initially set to 0 methods: getName() - returns name getAge() - returns age getWeight() - returns weight greet() - logs a message with person's name eat() - increment weight, increment mood exercise() - decrement weight ageUp() - increment age, increment height, increment weight, decrement mood, increment bank account by 10 (birthday money) buyHamster(hamster) - push the hamster object onto the hamster array, increment mood by 10, decrement bankAccount by the value of the hamster (hint: use getPrice()) ------------------------------------------------------- Create a Story with your Person class Feel free to update or add methods to automate some of these tasks. Instantiate a new Person named Timmy Age Timmy five years At this point Timmy's a little bummed. As a precocious child, he feels he's "seen it all" already. Have him eat five times. Now Timmy's a little heavier than he wants to be. Kindergarten's coming up and he wants to look good. Have him exercise five times Age Timmy 9 years Create a hamster named "Gus" Set Gus's owner to the string "Timmy" Have Timmy "buy" Gus Age Timmy 15 years Have Timmy eat twice Have Timmy exercise twice ------------------------------------------------------- Chef Make Dinners class Dinner { } class Chef { } Chef should be a factory of Dinner Add a constructor to dinner that sets the string properties, appetizer, entree and dessert. Add a method on chef that takes three arguments and returns a new Dinner based on those arguments. Have the Chef create 3 dinners, log the dinners -------------------------------------------------------

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_2

Step: 3

blur-text-image_3

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 Visualization A Practical Introduction

Authors: Kieran Healy

1st Edition

0691181624, 978-0691181622

More Books

Students also viewed these Databases questions

Question

1. List the steps in the recruitment and selection process.

Answered: 1 week ago

Question

SAFETY IS YOUR RESPONSIBILITY TAKE CARE

Answered: 1 week ago