Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bedrag
- {
- private int euro;
- private int cent;
- public Bedrag()
- {
- }
- public Bedrag(int euro, int cent)
- {
- if (euro > 0 && cent > 0){
- setEuro(euro);
- setCent(cent);
- }
- else{
- System.out.println("Bedrag moet groter zijn dan 0");
- }
- }
- public int getEuro()
- {
- return euro;
- }
- public int getCent()
- {
- return cent;
- }
- public void setEuro(int euro)
- {
- this.euro=euro;
- }
- public void setCent(int cent)
- {
- this.cent=cent;
- }
- public int getBedragInCent()
- {
- return this.euro*100 + this.cent;
- }
- public double getBedragInEuroEnCent()
- {
- double bedrag= (double)this.cent/100 + euro;
- System.out.println(bedrag + " is " + (euro) + " euro en " + (this.cent % 100) + " cent." );
- return bedrag;
- }
- public boolean isMinder(Bedrag b2)
- {
- return(((double)this.cent/100 + this.euro) < ((double)b2.getBedragInCent() /100));
- }
- public void setTotaalBedrag(int tot)
- {
- this.setEuro(tot/100);
- this.setCent(tot %100);
- }
- public Bedrag addBedrag(double b3)
- {
- Bedrag b = new Bedrag();
- b.setTotaalbedrag((this.cent + this.euro*100) + (b3.getBedragInCent()));
- return b;
- }
- }
Add Comment
Please, Sign In to add comment