O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming Exercises

1:Write a class called SportsCar containing the two instance variables maxSpeed and horsepower of type int. Both these instance variables must, in any SportsCar object, hold values that are greater than certain pre-specified values; otherwise, they do not qualify as proper SportsCar objects. In our case, the minimum value for maxSpeed is 200 kilometers/hour, and the minimum value for horsepower is 250 hp. Include suitable member variables in the SportsCar class to hold these values (called maxSpeedRequirement and horsepowerRequirement) and write a method called SportsCheck that returns true if both of the maxSpeed and horsepower for a particular SportsCar object are above the minimum requirements; otherwise, false. Write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required