Special offer for new customers: 5% OFF your first order! Use coupon: GWRITERSclose

java program

Exercise 1A) Write a class called SportsCar containing the two instance variables maxSpeed and horsepowerof 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 SportsCarobjects. In our case, the minimum value for maxSpeed is 200 km/hour, and the minimum value for horsepower is 250hp. Include suitable member variables in the SportsCar class to hold these values (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 accessor and mutator methods for maxSpeed, horsepower, maxSpeedRequirement and horsepowerRequirement.

Exercise 2A) Write a class called Robot with the following three instance variables: name (string), age (ushort), isOn (bool). Make the program initialize the instance variables to unknown, 0, and false, respectively (without using constructors). Include accessor and mutator methods to assign and retrieve the values of these instance variables. B) Allow the users of the Robot class to set the initial values of the three instance variables when a Robot object is created. To this end declare one constructor with three formal parameters and one default constructor.C) Include a member variable called robotsCreated that keeps track of the number of Robot objects created. Make the constructors update the robotsCreated variable so it is always up to date. Implement the following logic: If robotsCreated is less than 5 when the constructor is called, set isOn to true; otherwise false.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes