Win a copy of Practical SVG this week in the HTML/CSS/JavaScript 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
}
}
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!