import javax.swing.JOptionPane; interface Vehicle { public void start(int a); public void stop(int b); }
class Bus implements Vehicle { public void start(int a) {
System.out.println(\"Bus开车时的人数:\"+a); } public void stop(int a) {
System.out.println(\"Bus停车时的人数:\"+a); } } class Bike implements Vehicle{
public void start(int b) {
System.out.println(\"Bike开车时的人数:\"+b); } public void stop(int b) {
System.out.println(\"Bike停车时的人数:\"+b);} } public class InterfaceDemo {
public
static
void
main(String[]
args)
{
String
a=JOptionPane.showInputDialog(\"请输入Bus上star 时的人数!\");
int bus1=Integer.parseInt(a);
String b=JOptionPane.showInputDialog(\"请输入Bus上stop时的人数!\");
int bus2=Integer.parseInt(b);
String c=JOptionPane.showInputDialog(\"请输入Bike上star时的人数!\");
int bike1=Integer.parseInt(c);
String d=JOptionPane.showInputDialog(\"请输入Bike上的stop时人数!\");
int bike2=Integer.parseInt(d);
Bus bus=new Bus(); bus.start(bus1); bus.stop(bus2); Bike bike=new Bike(); bike.start(bike1); bike.stop(bike2); } }
因篇幅问题不能全部显示,请点此查看更多更全内容