Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

if this could be done in Python (30 points) You have been hired by Automatic GreenLawns.com to write an app to allow a homeowner to

if this could be done in Python image text in transcribed
image text in transcribed
(30 points) You have been hired by Automatic GreenLawns.com to write an app to allow a homeowner to control their lawn sprinklers through their phones. Each Sprinkler object will have the following instance variables: 1) state, a boolean that will be True if the sprinkler is on and False if the sprinkler is off. 2) runTime, an integer which represents how many minutes the sprinkler will be on for before automatically shutting off. For example, if I want the sprinkler to run for 45 minutes, I would set runtime to 45. 3) count is an integer which represents how many minutes the sprinkler has been on. When count equals runtime the sprinkler should turn off. The Sprinkler constructor will initialize runtime to a value passed in, state will be initialized to False, and count initialized to 0. Sprinkler methods are: 1) turnOn will set state to True 2) turnOff will set state to False 3) getRunTime will return runTime 4) getCount will return count 5) getState will return state 6) setCount will accept an integer as a parameter and set count to this value No other methods are needed. Part 1 Write the sprinkler class Part 2 Write a program called sprinklerController that uses the class Sprinkler. minutes, I would set runtime to 45. 3) count is an integer which represents how many minutes the sprinkler has been on. When count equals runtime the sprinkler should turn off. "The Sprinkler constructor will initialize runtime to a value passed in, state will be initialized to False, and count initialized to 0. Sprinkler methods are: 1) turnon will set state to True 2) turnOff will set state to False 3) getRunTime will return runTime 4) getCount will return count 5) getState will return state 6)setCount will accept an integer as a parameter and set count to this value No other methods are needed. Part 1 Write the sprinkler class Part 2 Write a program called sprinklerController that uses the class Sprinkler. 1) The program should create 2 sprinklers, frontLawn with a runtime of 60 minutes and backLawn with a runTime of 45 minutes 2) Turn the frontLawn and the backLawn sprinklers on. 3) Write a loop which continues as long as one of the sprinklers is on. Each time through the loop, increment the count of only the sprinklers that are on. Remember that when count equals runtime the sprinkler should turn off

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

6 Transfer does not happen by chance. Discuss

Answered: 1 week ago