store.java

来自「翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案」· Java 代码 · 共 40 行

JAVA
40
字号
//: Store.java

interface Product {
	static final String MAKER = "My Corp";
	static final String PHONE = "7963628";
	public int getPrice(int id);
}

class Shoe implements Product {
	public int getPrice(int id) {
		if ( id == 1 )
			return 5;
		else
			return 10;
	}
	public String getMaker() {
		return MAKER;
	}
}

public class Store {
	static Shoe hightop;
	public static void init() {
		hightop = new Shoe();
	}
	public static void main(String[] args) {
		init();
		getInfo(hightop);
		orderInfo(hightop);
	}
	public static void getInfo(Shoe item) {
		System.out.println("This Product is made by " + item.MAKER);
		System.out.println("It cost $" + item.getPrice(1));
	}
	public static void orderInfo(Product item) {
		System.out.println("To order from " + item.MAKER + " call " + item.PHONE + ".");
		System.out.println("Each item costs $" + item.getPrice(1));
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?