Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using interface and how to implement them

 
Duc Nguy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to develop number of vehicle types using the following interface. How do i use them
public interface Driveable
{
public static final int LEFT = 0;
public static final int RIGHT = 1;
public void start();
public void stop();
public void accelerate();
public void decelrate();
public void turn (int direction);
}
I have to write an classs for van, sedan that implement the inerface. please help.
 
James Hobson
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you want something like this
/**
* Put some javadoc here
*/
public class Van implements Driveable {
public static void main(String args) {
Driveable aVanInstance = new Van();
aVanInstance.start();
aVanInstance.turn(90);
aVanInstance.stop();
}

public void start() {
//do something
}
public void stop() {
//do something
}
public void accelerate(){
//do something
}
public void decelrate(){
//do something
}
public void turn (int direction){
//do something
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic