boogler boogler
forum van 1tx2a/b
 
 FAQFAQ   ZoekenZoeken   GebruikerslijstGebruikerslijst   GebruikersgroepenGebruikersgroepen   RegistrerenRegistreren 
 ProfielProfiel   Log in om je privéberichten te bekijkenLog in om je privéberichten te bekijken   InloggenInloggen 

Klasse euro

 
Nieuw onderwerp plaatsen   Reageren    boogler -> samenvattingen
Vorige onderwerp :: Volgende onderwerp  
Auteur Bericht
stekkew



Geregistreerd op: 06 Okt 2010
Berichten: 44
Woonplaats: Herent

BerichtGeplaatst: 21-10-2010 16:41:29    Onderwerp: Klasse euro Reageren met citaat

public class Euro {

private int euro;
private int cent;

public Euro(){
setEuro(0);
setCent(0);
}

public Euro(int euro, int cent){
setEuro(euro);
setCent(cent);
}

public int getEuro(){
return euro;
}

public int getEC(){
return cent;
}

public void setEuro(int e){
if(e >= 0 && e < 100){
this.euro = e;
}
else if(e > 100){
this.euro = this.euro + (e/100);
this.cent = this.cent + (e%100);
}
else{
System.out.println("Je kan geen negatief getal hebben");
this.cent = 0;
this.euro = 0;
}
}

public void setCent(int c){
if (c >= 0 && c<100){
this.cent = this.cent + c;
}
else if(c >= 100 && this.euro!=0){
this.euro = this.euro + (c/100);
this.cent = this.cent + (c%100);
}
else{
System.out.println("Je kan niet minder dan 0 cent hebben...");
this.euro = 0;
this.cent = 0;
}
}

public int zetOmInCent(){
int aantalCent = this.cent + this.euro*100;
return aantalCent;
}

public String toString(){
String uitvoer = new String("Je hebt " + this.euro + " euro en " + this.cent + " cent.");
return uitvoer;
}

public Euro addEuro(Euro bedrag){
Euro nieuwBedrag = new Euro();
int nieuwEuro = 0;
int nieuwCent = 0;
if(bedrag == null){
nieuwBedrag = null;
}
else{
nieuwEuro = this.euro + bedrag.getEuro();
nieuwCent = this.cent + bedrag.getEC();
nieuwBedrag = new Euro(nieuwEuro, nieuwCent);
}
return nieuwBedrag;
}

public Euro subtractEuro(Euro bedrag){
int nieuwEuro = 0;
int nieuwCent = 0;

if bedrag

if(this.euro >= bedrag.getEuro()){
nieuwEuro = this.euro - bedrag.getEuro();
}
else{
System.out.println("Je hebt te weinig euro's...");
}

if(this.cent >= bedrag.getEC()){
nieuwCent = this.cent - bedrag.getEC();
}
else{
System.out.println("Je hebt te weinig centen...");
}

Euro nieuwBedrag = new Euro(nieuwEuro, nieuwCent);
return nieuwBedrag;
}

public boolean isMinder(Euro bedrag){
boolean test = false;
if(bedrag == null){
test = false;
}
else{
if (this.zetOmInCent() < bedrag.zetOmInCent()){

test = true;
}
else{
test = false;
}
}
return test;
}

public boolean isZelfde(Euro bedrag){
boolean test = false;
if(bedrag == null){
test = false;
}
else{ if(this.zetOmInCent() == bedrag.zetOmInCent()){
test = true;
}
else{
test = false;
}
}
return test;
}

}
Terug naar boven
Profiel bekijken Stuur privébericht
berghmansseppe
Site Admin


Geregistreerd op: 06 Okt 2010
Berichten: 17
Woonplaats: wezelhoevenweg 41a

BerichtGeplaatst: 21-10-2010 16:47:38    Onderwerp: Re: Klasse euro Reageren met citaat

stekkew schreef:
public class Euro {

private int euro;
private int cent;

public Euro(){
setEuro(0);
setCent(0);
}

public Euro(int euro, int cent){
setEuro(euro);
setCent(cent);
}

public int getEuro(){
return euro;
}

public int getEC(){
return cent;
}

public void setEuro(int e){
if(e >= 0 && e < 100){
this.euro = e;
}
else if(e > 100){
this.euro = this.euro + (e/100);
this.cent = this.cent + (e%100);
}
else{
System.out.println("Je kan geen negatief getal hebben");
this.cent = 0;
this.euro = 0;
}
}

public void setCent(int c){
if (c >= 0 && c<100){
this.cent = this.cent + c;
}
else if(c >= 100 && this.euro!=0){
this.euro = this.euro + (c/100);
this.cent = this.cent + (c%100);
}
else{
System.out.println("Je kan niet minder dan 0 cent hebben...");
this.euro = 0;
this.cent = 0;
}
}

public int zetOmInCent(){
int aantalCent = this.cent + this.euro*100;
return aantalCent;
}

public String toString(){
String uitvoer = new String("Je hebt " + this.euro + " euro en " + this.cent + " cent.");
return uitvoer;
}

public Euro addEuro(Euro bedrag){
Euro nieuwBedrag = new Euro();
int nieuwEuro = 0;
int nieuwCent = 0;
if(bedrag == null){
nieuwBedrag = null;
}
else{
nieuwEuro = this.euro + bedrag.getEuro();
nieuwCent = this.cent + bedrag.getEC();
nieuwBedrag = new Euro(nieuwEuro, nieuwCent);
}
return nieuwBedrag;
}

public Euro subtractEuro(Euro bedrag){
int nieuwEuro = 0;
int nieuwCent = 0;

if bedrag

if(this.euro >= bedrag.getEuro()){
nieuwEuro = this.euro - bedrag.getEuro();
}
else{
System.out.println("Je hebt te weinig euro's...");
}

if(this.cent >= bedrag.getEC()){
nieuwCent = this.cent - bedrag.getEC();
}
else{
System.out.println("Je hebt te weinig centen...");
}

Euro nieuwBedrag = new Euro(nieuwEuro, nieuwCent);
return nieuwBedrag;
}

public boolean isMinder(Euro bedrag){
boolean test = false;
if(bedrag == null){
test = false;
}
else{
if (this.zetOmInCent() < bedrag.zetOmInCent()){

test = true;
}
else{
test = false;
}
}
return test;
}

public boolean isZelfde(Euro bedrag){
boolean test = false;
if(bedrag == null){
test = false;
}
else{ if(this.zetOmInCent() == bedrag.zetOmInCent()){
test = true;
}
else{
test = false;
}
}
return test;
}

}
subustract is nog NIE af !
Terug naar boven
Profiel bekijken Stuur privébericht E-mail versturen MSN Messenger
Berichten van afgelopen:   
Nieuw onderwerp plaatsen   Reageren    boogler -> samenvattingen Tijden zijn in GMT + 1 uur
Pagina 1 van 1

 
Ga naar:  
Je mag geen nieuwe onderwerpen plaatsen in dit subforum
Je mag geen reacties plaatsen in dit subforum
Je mag je berichten niet bewerken in dit subforum
Je mag je berichten niet verwijderen in dit subforum
Je mag niet stemmen in polls in dit subforum


Wilt u geen reclame op dit forum en genieten van extra voordelen? Klik dan vlug hier voor meer informatie!
 

Powered by phpBB
immo op Realo
Maak snel, eenvoudig en gratis uw eigen forum: Gratis Forum