Jump to content

User:Linusrock/sandbox

From Wikipedia, the free encyclopedia

public class BioGasPowerGeneration extends PowerGenerationPlant { private String typeOfBioWaste; private float amtOfBioWasteInTonsPerUnit; private static int counter=5000; public BioGasPowerGeneration(int noOfPowGenUnits, String typeOfBioWaste, float amtOfBioWasteInTonsPerUnits) { super(noOfPowGenUnits); this.plantId="Bio-Gas"+ ++counter; this.typeOfBioWaste = typeOfBioWaste; this.amtOfBioWasteInTonsPerUnit = amtOfBioWasteInTonsPerUnits; } public String getTypeOfBioWaste() { return typeOfBioWaste; } public float getAmtOfBioWasteInTonsPerUnits() { return amtOfBioWasteInTonsPerUnit; } public void validateTypeOfBioWaste(){

if(typeOfBioWaste.equals("Animal Waste")) { getNoOfPowGenUnits(); } else if(typeOfBioWaste.equals("Animal Waste")) { getNoOfPowGenUnits(); } else if (typeOfBioWaste.equals("Animal-Plant Mixtue")){ getNoOfPowGenUnits(); } else { typeOfBioWaste.equals("Animal-Plant Mixtue"); } } public void validateAmtOfBioWasteInTonesPerUnit(){ if(amtOfBioWasteInTonsPerUnit<100){ amtOfBioWasteInTonsPerUnit=100; } } public int calculateCostOfPowGen(){ if(validateNoOfPowGenUnits()==true){ if(typeOfBioWaste.equals("Animal Waste")){ getNoOfPowGenUnits(); } else if(typeOfBioWaste.equals("Plant Waste")){ getNoOfPowGenUnits(); } }else if(typeOfBioWaste.equals("Animal-Plant Mixture")){ getNoOfPowGenUnits(); }

int TotalPowerGenInKW=0; int TotalCostOfPower=0; TotalPowerGenInKW=(int) (getNoOfPowGenUnits()+ amtOfBioWasteInTonsPerUnit); if (TotalPowerGenInKW<1000000){ TotalCostOfPower= TotalPowerGenInKW*3; return TotalCostOfPower; } if (TotalPowerGenInKW>1000000 && (TotalPowerGenInKW<2000000)){ TotalCostOfPower= 1000000*6+ (TotalPowerGenInKW-1000000)*3 ; return TotalCostOfPower; }

if (TotalPowerGenInKW>2000000){ TotalCostOfPower= 1000000*3+1000000*6+(TotalPowerGenInKW-2000000)*9; return TotalCostOfPower; }

else { return 0; }

} }

codezuluzulu

[edit]

public class BioGasPowerGeneration extends PowerGenerationPlant { private String typeOfBioWaste; private float amtOfBioWasteInTonsPerUnit; private static int counter=5000; public BioGasPowerGeneration(int noOfPowGenUnits, String typeOfBioWaste, float amtOfBioWasteInTonsPerUnits) { super(noOfPowGenUnits); this.plantId="Bio-Gas"+ ++counter; this.typeOfBioWaste = typeOfBioWaste; this.amtOfBioWasteInTonsPerUnit = amtOfBioWasteInTonsPerUnits; } public String getTypeOfBioWaste() { return typeOfBioWaste; } public float getAmtOfBioWasteInTonsPerUnits() { return amtOfBioWasteInTonsPerUnit; } public void validateTypeOfBioWaste(){

if(typeOfBioWaste.equals("Animal Waste")) { getNoOfPowGenUnits(); } else if(typeOfBioWaste.equals("Animal Waste")) { getNoOfPowGenUnits(); } else if (typeOfBioWaste.equals("Animal-Plant Mixtue")){ getNoOfPowGenUnits(); } else { typeOfBioWaste.equals("Animal-Plant Mixtue"); } } public void validateAmtOfBioWasteInTonesPerUnit(){ if(amtOfBioWasteInTonsPerUnit<100){ amtOfBioWasteInTonsPerUnit=100; } } public int calculateCostOfPowGen(){ if(validateNoOfPowGenUnits()==true){ if(typeOfBioWaste.equals("Animal Waste")){ getNoOfPowGenUnits(); } else if(typeOfBioWaste.equals("Plant Waste")){ getNoOfPowGenUnits(); } }else if(typeOfBioWaste.equals("Animal-Plant Mixture")){ getNoOfPowGenUnits(); }

int TotalPowerGenInKW=0; int TotalCostOfPower=0; TotalPowerGenInKW=(int) (getNoOfPowGenUnits()+ amtOfBioWasteInTonsPerUnit); if (TotalPowerGenInKW<1000000){ TotalCostOfPower= TotalPowerGenInKW*3; return TotalCostOfPower; } if (TotalPowerGenInKW>1000000 && (TotalPowerGenInKW<2000000)){ TotalCostOfPower= 1000000*6+ (TotalPowerGenInKW-1000000)*3 ; return TotalCostOfPower; }

if (TotalPowerGenInKW>2000000){ TotalCostOfPower= 1000000*3+1000000*6+(TotalPowerGenInKW-2000000)*9; return TotalCostOfPower; }

else { return 0; }

} }