You will design and implement classes for cars. There are three types of cars: S
ID: 3539532 • Letter: Y
Question
You will design and implement classes for cars. There are three types
of cars: Sedan, Compact, and Sports. Each car contains an integer amount of gas. All cars
respond to the gas feature, which increments the amount of gas by 1 up to a maximum of
50, and prints out "Gas!" to the standard output. Except the Compact car, which after
printing "Gas!" also prints "Well, I have to work hard again".
All cars respond to the accelerate feature, which decreases the amount of the gas by 1 and
increases the speed of a car by 1. A car prints out "Faster!" when it receives the accelerate
feature. However, Sports cars get so excited that they prints "It really feels good!" which
costs the Sports car two more units of gas, but increases the speed by another one. All
the cars respond to the brake feature, which decreases the amount of the gas, as well as
speed, by 1. The speed is represented by an integer between 0 and 200, except for a Sports
car, which can reach 300. When the speed is greater than (3* gas - 50), a car responds
by printing "Speeding!" A Sedan car will further complain "Why hurry?" The exertion of
printing the extra words costs Sedan an additional unit of gas
Draw a class hierarchy in BON, which species the relationships among all classes you
designed (no interface details). Also, implement your classes in Eiel with suitable con-
tracts and invariants. Your design should be general enough to easily add new types of
cars. The code should be in Eiffel
Explanation / Answer
Is Eiffel a language? Do u need the code to be in eiffel only? Would C++ work?
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.