Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. public class Bedrag
  2. {
  3.     private int euro;
  4.     private int cent;
  5.  
  6.  public Bedrag()
  7.  {
  8.  }
  9.  
  10.   public Bedrag(int euro, int cent)
  11.  {
  12.     if (euro > 0 && cent > 0){
  13.     setEuro(euro);
  14.     setCent(cent);
  15. }
  16. else{
  17. System.out.println("Bedrag moet groter zijn dan 0");
  18. }
  19.  }
  20.  
  21.  public int getEuro()
  22.  {
  23.  return euro;  
  24.  }
  25.  
  26.  public int getCent()
  27.  {
  28.  return cent;  
  29.  }
  30.  
  31.  public void setEuro(int euro)
  32.  {
  33.      this.euro=euro;
  34.  }
  35.  
  36.  public void setCent(int cent)
  37.  {
  38.      this.cent=cent;
  39.  }
  40.  
  41.  public int getBedragInCent()
  42.  {
  43.     return this.euro*100 + this.cent;
  44.    
  45.  }
  46.  
  47.  public double getBedragInEuroEnCent()
  48.  {
  49.    
  50.     double bedrag= (double)this.cent/100 + euro;
  51.     System.out.println(bedrag + " is " + (euro) + " euro en " + (this.cent % 100) + " cent." );
  52.  return bedrag;
  53.      
  54.  
  55. }
  56.  
  57. public boolean isMinder(Bedrag b2)
  58. {
  59.     return(((double)this.cent/100 + this.euro) < ((double)b2.getBedragInCent() /100));
  60. }
  61.  
  62. public void setTotaalBedrag(int tot)
  63. {
  64.     this.setEuro(tot/100);
  65.     this.setCent(tot %100);
  66. }
  67.  
  68. public Bedrag addBedrag(double b3)
  69. {
  70.     Bedrag b = new Bedrag();
  71.     b.setTotaalbedrag((this.cent + this.euro*100) + (b3.getBedragInCent()));
  72.     return b;
  73. }
  74.  
  75. }
Add Comment
Please, Sign In to add comment