This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes using interface and how to implement them Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using interface and how to implement them" Watch "using interface and how to implement them" New topic
Author

using interface and how to implement them

Duc Nguy
Greenhorn

Joined: Nov 12, 2001
Posts: 7
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

Joined: Aug 28, 2001
Posts: 140
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
}
}
 
wood burning stoves
 
subject: using interface and how to implement them
 
Similar Threads
Requirement of Interface in Java
Interface Concept in anonymous classes///
why not use interfaces for constants?
How to define constants for several classes?
(static ) variables in multple classes