View the step-by-step solution to:

Question

<ul><li>Call your class Car.</li><li> __init__() method with self as the only

parameter. This method should do the following: ◦ Setanattributex(representingthecar'sxcoordinate)to0.</li><li>◦ Setanattributey(representingthecar'sycoordinate)to0.</li><li>◦ Setanattributeorient(representingthecar'sorientation)to"n"(fornorth).</li><li>◦ Setanattributegas(representingtheamountofgasinthecar'stank)to10.0.</li><li>a drive() method with parameters self and reverse. reverse should take a Boolean value; give it a default value of False. This method should do the following:</li><li>Ifthegasattributeislessthan0.2,raiseaRuntimeError.</li><li>Thismethodshouldchangethexoryattributedependingonthevalueoftheorientattributeandthe</li><li>parameter reverse. When driving north, decrease y by 1; south, increase y by 1; west, decrease x by 1; east,</li><li>increase x by 1.</li><li>Thismethodshoulddecreasethegasattributeby0.2.</li><li>a turn() method with parameters self and dir (for direction). dir should be 'l' or 'r'. This method should do the following:</li><li>◦ Changetheorientattributedependingonthevalueofdir.Forexample,iforientwas'n'anddiris'r',</li><li>orient should become 'e'.</li><li> a refill() method with self as the only parameter. This method should do the following:</li><li>◦ Setthegasattributeto10.0.</li><li> a status() method with self as the only parameter. This method should do the following:</li><li>◦ Printamessageindicatingthecar'scurrentpositionandorientationandtheamountofgasinthetank.</li><li>Write docstrings for each method. (__init__() doesn't need a docstring.)</li><li>Make an if __name__ == "__main__": statement in which you can.an instance of your class and invoke each method (you don't have to explicitly invoke __init__()).</li></ul>

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Python Programming tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors