Question

Python Code Question# 1 General Instructions Create a class called LawnService that takes in the length...

Python Code Question# 1

General Instructions

Create a class called LawnService that takes in the length and width of a yard, along with the current state of the yard. The currect state can be: poor, acceptable or great. Within this class include a constructor that will assign these values to attributes. Additionally create three methods that will be named and do the following:

*DetermineApplication: This method will focus on the lawn status attribute. If the status is poor, the lawn company will need to visit the household twice a month for 6 months. If the status is acceptable, the lawn company will need to visit once a month for 6 months. Finally if the lawn is great, the lawn company will visit every other month for 6 months.

*DetermineTotal: This method will use the number of applications as determined by the method DetermineApplication to calculate the total cost to the customer. The calculation will first determine the area using the lenght and width. For each square foot of lawn the lawn company charges $0.05. The total cost will include the cost for each application by how many applications are necessary as determined by DetermineApplication. *ReturnTotal: This method returns the total cost to the customer.

Analyzing the Requiements

Before you code, make sure you have identifed what the data requirements are for this class. Is there any data that needs to come in to the class in order for it to work? Is there any data processed in this class? What data needs to leave this class? Once you have the data requirements figured out, detemine the methods for this class along with their algorithms. Finally determine what data needs to leave the class and what access methods you will need to write in order for that to happen.

Writing the Code

After figuring out what your class needs to do, open up your Python compiler and create your constructor to declare and initialize your attributes. Then code your methods followed by the access methods. To test this in the compiler, create main() that will create your first object. Send in to the 40 for the width, 30 for the length and for the status "poor".

Call your method to determine the application, followed by the method to determine the total. Next call the method to return the total and print that to the screen. If your total is 720 your code is working. If your total is not this go back and check your decision structure in determine application. Next check your determine total method to make sure your math is correct. If you are unable to find your error by analzying each of these methods, place print statements within your methods to show you the values of your variables as your class executes. As soon as you get your code running and working, copy your code for the class only to Notepad++ to presearve the spacing followed by a copy and paste into MPL. Click on the submit button to run your code in MPL.

Testing and Output

There is no output for this class other than the words Corrrect and Great Job if you created the class correctly. MyProgramming Lab will run your code and create an object based on it.

Python Code Question# 2

General Instructions

Using the your LawnService class you created above, copy the code you wrote and paste it into the solution area. Then create an object based on your class. Name your object MyLawn. When creating your object use great as the lawn status, 50 as the length and 20 as the width for your parameters or the values that need to be sent into the class.

Testing and Output

There is no output for this class other than the words Corrrect and Great Job if you created the class correctly. MyProgramming Lab will run your code and create an object based on it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The python code is

class LawnService:
"""Creating LawnService class with DetermineApplication
and DetermineTotal cost methods """

time_visit=0
# constructor
def __init__(self,length,width,state):
self.length = length
self.width = width
self.state = state

def DetermineAppliacation(self):
'''This method will focus on the lawn status attribute. It changes
the value according to status attribute'''
if(self.state == "poor"):
self.time_visit = 12
elif(self.state == "acceptable"):
self.time_visit = 6
elif(self.state == "great"):
self.time_visit = 3

def DetermineTotal(self):
'''This method will use the number of applications as determined
by the method DetermineApplication to calculate
the total cost to the customer'''
self.DetermineAppliacation()
area = self.length*self.width
cstprtim = area*(0.05)
totatcost = self.time_visit*cstprtim
return totatcost

if __name__ == "__main__":
lawnser = LawnService(40, 30, "poor")
lawnser.DetermineAppliacation()   print("Checking the test case ")
print(lawnser.DetermineTotal())

The ouput is 720 and image is

I hope you got the answer and understand it.

Thank you:):)

Add a comment
Know the answer?
Add Answer to:
Python Code Question# 1 General Instructions Create a class called LawnService that takes in the length...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • Create a class called DuplicateRemover. Create an instance method called remove that takes a single parameter...

    Create a class called DuplicateRemover. Create an instance method called remove that takes a single parameter called dataFile (representing the path to a text file) and uses a Set of Strings to eliminate duplicate words from dataFile. The unique words should be stored in an instance variable called uniqueWords. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the words contained in uniqueWords to the file pointed...

  • Write Python code to create a class called Dog which represents a dog. The Dog class...

    Write Python code to create a class called Dog which represents a dog. The Dog class should have properties of breed (i.e. what type of dog it is), name and weight. The class should also have a constructor that takes these parameters to initialise the dog object, and a method called bark that prints out the word 'Woof!' to the screen. After you have defined the Dog class, create a Dog object called goodDog with a breed of 'terrier', a...

  • // Client application class and service class Create a NetBeans project named StudentClient following the instructions...

    // Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • In JAVA 1. Create a class called Rectangle that has integer data members named - length...

    In JAVA 1. Create a class called Rectangle that has integer data members named - length and width. Your class should have a default constructor (no arg constructor) Rectangle() that initializes the two instance variables of the object Rect1. The second overloading constructor should initializes the value of the second object Rect2. The class should have a member function named GetWidth() and GetLength() that display rectangle's length and width. OUTPUT: Rectl width: 5 Rectl length: 10 Enter a width :...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to...

    I need some help with programming this assignment. Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to write a Python class Be able to define class attributes Be able to define class methods .Be able to process input from a text file .Be able to write an application using objects The goal of this programming assignment is to develop a simple image processing application. The application will import a class that creates image objects with...

  • help asap in python codio, A good friend of yours owns a small company that produces...

    help asap in python codio, A good friend of yours owns a small company that produces a tool the helps disabled individuals open jars and containers. Rather than buy a time clock mechanism, he would like to put an old computer on the warehouse floor that could be used as the time clock and help them manage materials, shipments, etc. Your friend was able to find an inexpensive application to keep track of each employee’s hours. However, this application did...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT