// in Store.java
public class Store
{
public Shoe hightop;
// public static void init()
// {
// hightop = new Shoe(); // 这行报错,Shoe不识认
// }
public Store() //构造函数
{
hightop = new Shoe();
}
public void main(String[] args)
{
// init();
getInfo(hightop);
orderInfo(hightop);
}
public void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + item.MAKER);
System.out.println("It eosts S" + item.getPrice(1) + 'n');
}
public static void orderInfo(Shoe item)
{
System.out.println("To order from" + item.MAKER + "call"+ item.PHONE+".");
System.out.println("Each item cost S" + item.getPrice(1));
}
}
// in Shoe.java
public class Shoe implements Produce
{
public int getPrice(int id)
{
return id==1?5:10;
}
};//in Prodouce.java
public interface Produce
{
static final String MAKER = "My Crop";
static final String PHONE = "555-555-333";
public int getPrice(int id);
};
public class Store
{
public Shoe hightop;
// public static void init()
// {
// hightop = new Shoe(); // 这行报错,Shoe不识认
// }
public Store() //构造函数
{
hightop = new Shoe();
}
public void main(String[] args)
{
// init();
getInfo(hightop);
orderInfo(hightop);
}
public void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + item.MAKER);
System.out.println("It eosts S" + item.getPrice(1) + 'n');
}
public static void orderInfo(Shoe item)
{
System.out.println("To order from" + item.MAKER + "call"+ item.PHONE+".");
System.out.println("Each item cost S" + item.getPrice(1));
}
}
// in Shoe.java
public class Shoe implements Produce
{
public int getPrice(int id)
{
return id==1?5:10;
}
};//in Prodouce.java
public interface Produce
{
static final String MAKER = "My Crop";
static final String PHONE = "555-555-333";
public int getPrice(int id);
};
解决方案 »
- 请教个关于package和import的问题
- 一个可以独立运行的Java应用程序( ) ??(选择题)
- 请教大侠“网络视频”的问题!!!(JMF)
- 请问如何在用Graphics输出文字在超出Graphics宽度时能够折行显示?
- 怎样用Java得到系统的所有的逻辑盘符?
- java swing 怎么实现eclipse上的带图片的下拉列表,就是eclipse菜单下的那些,比如运行按钮
- 怎么删除文件中的一行?回答出马上结贴
- 怎么得到这样的小数
- 关于jframe,jinteralframe的最大化问题(大家快来看看,但是分数不太够)
- JAVA中实现一个接口的问题
- 请说明JAVA中时间处理的基本过程。
- 一个有关关闭画图的问题
public class Store
{
public Shoe hightop;
// public static void init()
// {
// hightop = new Shoe(); // 这行报错,Shoe不识认
// }
public Store() //构造函数
{
hightop = new Shoe();
}
public static void main(String[] args)
{
Store myStore = new Store();
getInfo(myStore.hightop);
orderInfo(myStore.hightop);
}
public static void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + item.MAKER);
System.out.println("It eosts S" + item.getPrice(1) + 'n');
}
public static void orderInfo(Shoe item)
{
System.out.println("To order from" + item.MAKER + "call"+ item.PHONE+".");
System.out.println("Each item cost S" + item.getPrice(1));
}
}
public interface Produce
{
static final String MAKER = "My Crop";
static final String PHONE = "555-555-333";
public int getPrice(int id);
};
// in Shoe.java
public class Shoe implements Produce
{
public int getPrice(int id)
{
return id==1?5:10;
}
};
// in Store.java
public class Store
{
public static Shoe hightop;
public static void init()
{
Shoe hightop = new Shoe(); // 这行报错,Shoe不识认
}
public static void main()
{
init();
getInfo(hightop);
orderInfo(hightop);
}
public static void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + item.MAKER);
System.out.println("It eosts S" + item.getPrice(1) + 'n');
}
public static void orderInfo(Shoe item)
{
System.out.println("To order from" + item.MAKER + "call"+ item.PHONE+".");
System.out.println("Each item cost S" + item.getPrice(1));
}
}
public interface Produce
{
static final String MAKER = "My Crop";
static final String PHONE = "555-555-333";
public int getPrice(int id);
};// in Shoe.java
public class Shoe implements Produce
{
public int getPrice(int id)
{
return id==1?5:10;
}
};// in Store.java
public class Store
{
public Shoe hightop;
〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉
// public static void init()
// {
// hightop = new Shoe; // 这行报错,Shoe不识认
// } public Store() //构造函数
{
hightop = new Shoe();
}
〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉
〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉
// public static void main() {
// init();
// getInfo(hightop);
// orderInfo(hightop);
//
// } public static void main(String args[]){
Store aStore = new Stroe();
aStore.getInfo(hightop);
aStore.orderInfo(hightop);
}
〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉〉
public static void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + Shoe.MAKER);//被修改
System.out.println("It eosts S" + item.getPrice(1) + 'n');
}
public static void orderInfo(Shoe item)
{
System.out.println("To order from" + Shoe.MAKERS + "call"+ item.PHONE+".");//被修改
System.out.println("Each item cost S" + item.getPrice(1));
}
}楼主还要好好学习面向对象思想才好,从最简单的开始吧
{
public int getPrice(int id)
{
return id==1?5:10;
}
}// in Store.java
public class Store
{
public Shoe hightop; public void init()
{
hightop = new Shoe();
} public static void main()
{
Store store = new Store();
store.init();
getInfo(store.hightop);
orderInfo(store.hightop); } public static void getInfo(Shoe item)
{
System.out.println("The Produce is made by :" + item.MAKER);
System.out.println("It eosts S" + item.getPrice(1) + 'n');
} public static void orderInfo(Shoe item)
{
System.out.println("To order from" + item.MAKER + "call"+ item.PHONE+".");
System.out.println("Each item cost S" + item.getPrice(1));
}
}public interface Produce
{
static final String MAKER = "My Crop";
static final String PHONE = "555-555-333";
public int getPrice(int id);
}