Advertisement
Guest User

Data Definition Class

a guest
Feb 14th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class Campaign{
  4.    private String campName;
  5.    private String campType;
  6.    private double campGoal=10000.0;
  7.    private double donationAmount;
  8.    private double donationTotal;
  9.    
  10.    Campaign(String campName, String campType, double campGoal, double donationAmount, double donationTotal) {
  11.       this.campName = campName;
  12.       this.campType = campType;
  13.       this.campGoal = campGoal;
  14.       this.donationAmount = donationAmount;
  15.       this.donationTotal = donationTotal;
  16.    }
  17.    
  18.    public String getCampName(){
  19.       return campName;
  20.    }
  21.    
  22.    public String getCampType(){
  23.       return campType;
  24.    }
  25.    
  26.    public double getCampGoal(){
  27.       return campGoal;
  28.    }
  29.    
  30.    public double getDonationAmount(){
  31.       return donationAmount;
  32.    }
  33.    
  34.    public void setCampName (String campName) {
  35.         this.campName = campName;
  36.     }
  37.    
  38.    public boolean setCampType(String campType){
  39.       if(campType.equalsIgnoreCase("Non Profit") || (campType.equalsIgnoreCase("For Profit"))){
  40.          this.campType=campType;
  41.          return true;
  42.      
  43.       }else{
  44.    
  45.          return false;
  46.       }
  47.    }
  48.    
  49.    public boolean setCampGoal(double campGoal){
  50.       if(campGoal>0 && campGoal<25000){
  51.          this.campGoal=campGoal;
  52.          return true;
  53.          
  54.       }else{
  55.      
  56.          return false;
  57.      }
  58.    }
  59.    /* this is to be removed if necessary(testing)
  60.    public boolean setDonationAmount(double donationAmount, double campGoal, double donationTotal){
  61.       if(donationAmount>0 && donationAmount<=campGoal){
  62.          this.donationAmount=donationAmount;
  63.          this.donationTotal+=donationAmount;
  64.          return true;
  65.          
  66.       }else{
  67.      
  68.          return false;
  69.      }
  70.     }
  71.    */
  72.    public double getDonationTotal(){
  73.       return donationTotal;
  74.     }
  75.    
  76.    public void setDonationTotal(double donationAmount){
  77.    if(donationAmount<=campGoal){
  78.       this.donationTotal+=donationAmount;
  79.      }
  80.     }
  81.    
  82.    
  83.    public double calculateFee(String campType, double donationTotal){
  84.       if(campType.equalsIgnoreCase("For Profit")){
  85.          return donationTotal+= (donationTotal - (donationTotal*0.05));
  86.       }else if(campType.equalsIgnoreCase("Non Profit")){
  87.          return donationTotal;
  88.       }else{
  89.          return donationTotal;
  90.     }
  91.    }
  92.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement