/*****************************************************************/ /* Copyright 2013 Code Strategies */ /* This code may be freely used and distributed in any project. */ /* However, please do not remove this credit if you publish this */ /* code in paper or electronic form, such as on a web site. */ /*****************************************************************/ package com.cakes; public abstract class Vehicle { Engine engine; int weightInKilos; public abstract void drive(); public void setEngine(Engine engine) { this.engine = engine; } public void reportOnSpeed(int horsepower) { int ratio = weightInKilos / horsepower; if (ratio < 3) { System.out.println("The vehicle is going at a fast speed."); } else if ((ratio >= 3) && (ratio < 8)) { System.out.println("The vehicle is going an average speed."); } else { System.out.println("The vehicle is going at a slow speed."); } } }