Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2016 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/18813c94279e728ca8f7 to your computer and use it in GitHub Desktop.
Save anonymous/18813c94279e728ca8f7 to your computer and use it in GitHub Desktop.
Data Definition Class
import javax.swing.JOptionPane;
public class Campaign{
private String campName;
private String campType;
private double campGoal=10000.0;
private double donationAmount;
private double donationTotal;
Campaign(String campName, String campType, double campGoal, double donationAmount, double donationTotal) {
this.campName = campName;
this.campType = campType;
this.campGoal = campGoal;
this.donationAmount = donationAmount;
this.donationTotal = donationTotal;
}
public String getCampName(){
return campName;
}
public String getCampType(){
return campType;
}
public double getCampGoal(){
return campGoal;
}
public double getDonationAmount(){
return donationAmount;
}
public void setCampName (String campName) {
this.campName = campName;
}
public boolean setCampType(String campType){
if(campType.equalsIgnoreCase("Non Profit") || (campType.equalsIgnoreCase("For Profit"))){
this.campType=campType;
return true;
}else{
return false;
}
}
public boolean setCampGoal(double campGoal){
if(campGoal>0 && campGoal<25000){
this.campGoal=campGoal;
return true;
}else{
return false;
}
}
public boolean setDonationAmount(double donationAmount, double campGoal, double donationTotal){
if(donationAmount>0 && donationAmount<=campGoal){
this.donationAmount=donationAmount;
this.donationTotal+=donationAmount;
return true;
}else{
return false;
}
}
public double getDonationTotal(){
return donationTotal;
}
public void setDonationTotal(double donationAmount){
donationTotal+=donationAmount;
}
public double calculateFee(String campType, double donationTotal){
if(campType.equalsIgnoreCase("For Profit")){
return donationTotal+= (donationTotal - (donationTotal*0.05));
}else if(campType.equalsIgnoreCase("Non Profit")){
return donationTotal;
}else{
return donationTotal;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment