Program 7.13: A Car class that implements Import
To actually use this interface you create a class that includes a public double calculate_tariff() method and declare that the class implements Import. For instance here's one such class:
class Car implements Import {
String make;
String model;
int year;
int max_speed;
int weight
float price;
int num_passengers;
int num_wheels = 4;
int num_doors;
public double calculate_tariff() {
return price * 0.1;
}
}
Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
This Chapter
Examples
Home