⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multipleinterfacevariants31.java

📁 Thinking In Java 第四版练习题答案
💻 JAVA
字号:
// generics/MultipleInterfaceVariants31.java
// TIJ4 Chapter Generics, Exercise 31, page 697
// Remove all generics from MultipleInterfaceVariants.java and modify
// the code so that the example compiles.

interface Payable { float getPay(); }

class Employee implements Payable {
	private float weeklyPay;
	public float getPay() {
		return weeklyPay;
	}		
} 

class Hourly extends Employee {
	public String name;
	protected float hourlyPay;
	public int hoursWorked;
	Hourly(String s, float pay, int hours) {
		name = s;
		hourlyPay = pay;
		hoursWorked = hours;
	}
	public float getPay() {
		System.out.println("Pay " + name + 
			" $" + hourlyPay * hoursWorked);
		return hourlyPay * hoursWorked;	
	}
}

public class MultipleInterfaceVariants31 {
	public static void main(String[] args) {
		Hourly h = new Hourly("Joe", 50.00f, 40);
		h.getPay();
	}
}

⌨️ 快捷键说明

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