Rate.java
上传用户:yinzh02
上传日期:2021-05-28
资源大小:63k
文件大小:2k
- /*
- * %W% %E% Rongzhi Liu
- *
- * Copyright (c) 2008 Rongzhi-Liu SUN YAT-SEN UNIVERSITY. All Rights Reserved.
- *
- * This software is to calculate personal tax.
- * To make its use wider, the base of tax and the Tax Rate Table can be change
- * is necessary.
- */
- package personaltax;
- /**
- * Class Rate contains the infomation of a single level, incluing its starting
- * money and the rate.
- *
- * @version 1.0 09 March 2008
- * @author Rongzhi-Liu
- */
- public class Rate {
-
- /** The starting money of the rank. */
- private double start;
-
- /** The rate of the rank. */
- private double rate;
-
- /** Default constructor. Do nothing. */
- public Rate(){}
-
- /** Constructor. */
- public Rate(double s, double r){
- start = s;
- rate = r;
- }
- /**
- * Get the starting money.
- *
- * @return the starting money.
- */
- public double getStart(){
- return start;
- }
-
- /**
- * Get the rate.
- *
- * @return the rate.
- */
- public double getRate(){
- return rate;
- }
-
- /**
- * Override toString()
- *
- * @return Fomated rate output.
- */
- @Override
- public String toString(){
- return start + "t " + rate;
- }
-
- /**
- * Override equals()
- */
- @Override
- public boolean equals(Object o){
- Rate r = (Rate)o;
- return (start == r.start) && (rate == r.rate);
- }
- /**
- * Override hashCode()
- */
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 47 * hash + (int) (Double.doubleToLongBits(this.start) ^ (Double.doubleToLongBits(this.start) >>> 32));
- hash = 47 * hash + (int) (Double.doubleToLongBits(this.rate) ^ (Double.doubleToLongBits(this.rate) >>> 32));
- return hash;
- }
-
- /**
- * Calculate the tax involving the Rank.
- *
- * @param AmountOfTax Money that should be taxed.
- * @return The tax.
- */
- public double calculate(double amountOfTax){
- return (amountOfTax - start) * rate;
- }
- }