What data and methods do objects of the class Senator have.
//=============================================================================
public class Politician {
//-----------------------------------------------------------------------------
private String name;
protected double fractionOfVote;
//-----------------------------------------------------------------------------
public Politician(String name) {
this.name = name;
fractionOfVote = 0.0;
}
//-----------------------------------------------------------------------------
public String toString() {
return(name);
}
//-----------------------------------------------------------------------------
public void setFractionOfVote(double fraction) {
fractionOfVote = fraction;
}
//-----------------------------------------------------------------------------
}
//=============================================================================
//=============================================================================
public class Senator extends Politician {
//-----------------------------------------------------------------------------
private String district;
private double moneySpentInElection;
//-----------------------------------------------------------------------------
public Senator(String name,String district,double moneySpent) {
super(name);
this.district = district;
moneySpentInElection = moneySpent;
}
//-----------------------------------------------------------------------------
public String toString() {
return(super.toString() + " from " + district);
}
//-----------------------------------------------------------------------------
public void getFractionOfVote() {
return(fractionOfVote);
}
//-----------------------------------------------------------------------------
}
//=============================================================================