Question

Design a Racing Car that can be used in a game and the Car must be able to be started, run, and s...

Design a Racing Car that can be used in a game and the Car must be able to be started, run, and stopped in Eclipse along with a UML. 1. The Car must have an Engine and Tires. 2. The Car must have four Tires. 3. The Car must have one Engine. 4. The Engine must be able to be started and stopped. 5. Before the Engine can be started all Tires must have at least 32 psi. 6. The Car must be able to be started, running between 1 and 60 mph, stopped, and also be able to be restarted.

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

class Car:
Engine=1
tyres=4
speed=0
def __init__(self, Engine, tyres, speed):
self.Engine = Engine
self.tyres = tyres
self.speed = speed

#methods
def start(self,speed,tyre_pressure):
if int(tyre_pressure)>=32:
self.speed +=int(speed)
if int(self.speed)>60:
self.speed=60
print 'Car running at speed:'+str(self.get_speed())
print '-----------------------------------------------------------'
print 'Maximum speed achieved. cannot increase more.'
print '-----------------------------------------------------------'
else:
print 'Car started at speed:'+str(self.get_speed())
print '-----------------------------------------------------------'

else:
print 'Increase air pressure in tyres'
print '-----------------------------------------------------------'


def stop(self):
self.speed=0

def get_speed(self):
return self.speed

def main():

Engine = raw_input('Enter the car Engines: ')
tyres = raw_input('Enter the car Tyres: ')
speed = 0

mycar = Car(Engine, tyres, speed)

#Start
run=int(raw_input("Enter 1 if you want to run the car: "))
print('*************************************************************')

if (run==1):
while(True):
speed=raw_input('Increase speed by :')
tyre_pressure=raw_input('Enter tyre pressure: ')
print('*************************************************************')

mycar.start(speed,tyre_pressure)
print "Enter 0 if you want to stop the car or 1 to continue."
print('*************************************************************')
run=int(raw_input())
if run==0:
break
else:
print('Car is steady')
print('*************************************************************')

mycar.stop()
print 'The current speed after brake is: ', mycar.get_speed()
print '-----------------------------------------------------------'


#Call the main function
main()

Command Prompt C:\Users\7320133 Documents\Practice\Python>python car.py Enter the car Engines: 1 Enter the car Tyres: 4 Enter

Add a comment
Know the answer?
Add Answer to:
Design a Racing Car that can be used in a game and the Car must be able to be started, run, and s...
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
  • (C++) The CSIT Racing Club is a group that runs amateur car racing events throughout the...

    (C++) The CSIT Racing Club is a group that runs amateur car racing events throughout the US. In This project, write a program that will help the club determine the winner of their Fall Rally Race. You will need to determine each racer’s average time and identify the first place finisher. An input file with race information contains records of all the laps run by each driver. The record for each driver includes the number of the car the driver...

  • Java 2 Final Project A young entrepreneur has decided to start an online exotic car sales...

    Java 2 Final Project A young entrepreneur has decided to start an online exotic car sales company named Exotic Moves and he’s contacted you to build the company’s website.  You have been given the following requirements and will need to create a prototype with JavaFX: The company sells 5 brands of exotic cars (Aston Martin, Ferrari, Lamborghini, McLaren, and Maserati).   The website should allow a user to see the total inventory of cars or filter their view based on certain...

  • PLEASE INCLUDE SAW-PROMPTS FOR 2 PLAYERS NAMES(VALIDATE NAMES). SHOW MENU (PLAYER MUST SELECT FROM MENU B4...

    PLEASE INCLUDE SAW-PROMPTS FOR 2 PLAYERS NAMES(VALIDATE NAMES). SHOW MENU (PLAYER MUST SELECT FROM MENU B4 THE GAME STARTS 1=PLAY GAME, 2=SHOW GAME RULES, 3=SHOW PLAYER STATISTICS, AND 4=EXIT GAME WITH A GOODBYE MESSAGE.) PLAYERS NEED OPTION TO SHOW STATS(IN A DIFFERNT WINDOW-FOR OPTION 3)-GAME SHOULD BE rock, paper, scissor and SAW!! PLEASE USE A JAVA GRAPHICAL USER INTERFACE. MUST HAVE ROCK, PAPER, SCISSORS, AND SAW PLEASE This project requires students to create a design for a “Rock, Paper, Scissors,...

  • For your Project, you will develop a simple battleship game. Battleship is a guessing game for...

    For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships (including battleships). The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the locations of the opponent’s ships. Players alternate turns by ‘firing torpedoes’ at the other player's ships. The...

  • CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As...

    CARD GAME (LINKING AND SORTING) DATA STRUCTURES TOPIC(S) Topic Primary Linked lists Sorting Searching Iterators As needed Recursion OBJECTIVES Understand linked lists and sorting concepts and the syntax specific to implementing those concepts in Java. PROJECT The final objective of this project is to create a multi-player card game, but you will create your classes in the order given, as specified. (Analogy: you must have a solid foundation before you can build a house). In order to allow creative freedom,...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

  • Can someone please show me a circuit diagram so i can see how to construct this...

    Can someone please show me a circuit diagram so i can see how to construct this on a bread board i am id 6 yhanks in advance EEET-2251: Course & Projoct Guide 2018 EEET-2251: Cousc &Projoct Guide 2018 affic Light Controller A single switch must set your HC74 based state machine to the initial state (the U state This lab will get you to design a simple controller for a pedestrian crossing based on synchronous digital logic. You will master...

  • Please help with my car traffic simulator! Code that I already have below, I do not know how to...

    Please help with my car traffic simulator! Code that I already have below, I do not know how to start it off! public class IntersectionSimulation { private final static int EAST_WEST_GREEN_TIME = 30 ; private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ; private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ; private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ; private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...

  • Project 7: Vehicles 1 Objective In the last couple projects, you’ve created and used objects in...

    Project 7: Vehicles 1 Objective In the last couple projects, you’ve created and used objects in interesting ways. Now you’ll get a chance to use more of what objects offer, implementing inheritance and polymorphism and seeing them in action. You’ll also get a chance to create and use abstract classes (and, perhaps, methods). After this project, you will have gotten a good survey of object-oriented programming and its potential. This project won’t have a complete UI but will have a...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

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