Complete the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information. Ex: If the input is: 2011 18000 2018 where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs: Car's information: Model year: 2011 Purchase price: $18000 Current value: $5770 Note: print_info() should use two spaces for indentation.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Complete the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information.
Ex: If the input is:
2011 18000 2018
where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs:
Car's information: Model year: 2011 Purchase price: $18000 Current value: $5770
Note: print_info() should use two spaces for indentation.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images