Skip to content

Commit 769152d

Browse files
authored
Fixed moisture (now 0 is dry, 1023 moist)
1 parent b0670ef commit 769152d

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

390application/app/src/main/java/com/example/a390application/MainActivity.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ protected void loadListView(){
227227
tempData+= "N/A" + "\n";
228228
}
229229
else{
230-
tempData+= String.format("%.0f",plants.get(i).getMoisture()) + " units";
230+
tempData+= String.format("%.0f",(1023-plants.get(i).getMoisture())) + " units";
231231
if(plants.get(i).getType().equals("Devil's Ivy")){
232232
if(moistureSmileyDevilsIvy(plants.get(i))>=75){
233233
tempData+= " " + emojiHappy + "\n";
@@ -610,11 +610,11 @@ protected double healthBarAlgoSansevieria(Plant givenPlant){ //specificall
610610
FinalTemperaturePercentage = givenPlant.getTemperature() * 4.3478; // 0 deg C = 0%
611611
}
612612

613-
if (givenPlant.getMoisture() >= 767){
614-
FinalMoisturePercentage = 100-((givenPlant.getMoisture()-767)*0.1953); // 1023 pts = 50%
613+
if ((1023-givenPlant.getMoisture()) >= 767){
614+
FinalMoisturePercentage = 100-(((1023-givenPlant.getMoisture())-767)*0.1953); // 1023 pts = 50%
615615
} // 767 pts = 100%
616616
else{
617-
FinalMoisturePercentage = givenPlant.getMoisture() * 0.1304; // 0 pts = 0 %
617+
FinalMoisturePercentage = (1023-givenPlant.getMoisture()) * 0.1304; // 0 pts = 0 %
618618
}
619619

620620
if (givenPlant.getLightIntensity() == 0){ // case uv = 0
@@ -640,11 +640,11 @@ protected double moistureSmileySansevieria(Plant givenPlant){ //specifical
640640

641641
double FinalMoisturePercentage;
642642

643-
if (givenPlant.getMoisture() >= 767){
644-
FinalMoisturePercentage = 100-((givenPlant.getMoisture()-767)*0.1953); // 1023 pts = 50%
643+
if ((1023-givenPlant.getMoisture()) >= 767){
644+
FinalMoisturePercentage = 100-(((1023-givenPlant.getMoisture())-767)*0.1953); // 1023 pts = 50%
645645
} // 767 pts = 100%
646646
else{
647-
FinalMoisturePercentage = givenPlant.getMoisture() * 0.1304; // 0 pts = 0 %
647+
FinalMoisturePercentage = (1023-givenPlant.getMoisture()) * 0.1304; // 0 pts = 0 %
648648
}
649649

650650
return FinalMoisturePercentage;
@@ -707,11 +707,11 @@ protected double healthBarAlgoEnglishIvy(Plant givenPlant){ //specifically
707707
FinalTemperaturePercentage = 50+(givenPlant.getTemperature() * 2.5); // -20deg C = 0%
708708
}
709709

710-
if (givenPlant.getMoisture() >= 256){
711-
FinalMoisturePercentage = Math.abs(100-((givenPlant.getMoisture()-256)*0.1304)); // 1023 pts (Dry) = 0%
710+
if ((1023-givenPlant.getMoisture()) >= 256){
711+
FinalMoisturePercentage = Math.abs(100-(((1023-givenPlant.getMoisture())-256)*0.1304)); // 1023 pts (Dry) = 0%
712712
} // 256 pts = 100%
713713
else{
714-
FinalMoisturePercentage = 50 + (givenPlant.getMoisture() * 0.1953); // 0 pts (wet) = 50%
714+
FinalMoisturePercentage = 50 + ((1023-givenPlant.getMoisture()) * 0.1953); // 0 pts (wet) = 50%
715715
}
716716

717717
if (givenPlant.getLightIntensity() == 0){ // case uv = 0
@@ -738,11 +738,11 @@ protected double moistureSmileyEnglishIvy(Plant givenPlant){ //specificall
738738

739739
double FinalMoisturePercentage;
740740

741-
if (givenPlant.getMoisture() >= 256){
742-
FinalMoisturePercentage = Math.abs(100-((givenPlant.getMoisture()-256)*0.1304)); // 1023 pts (Dry) = 0%
741+
if ((1023-givenPlant.getMoisture()) >= 256){
742+
FinalMoisturePercentage = Math.abs(100-(((1023-givenPlant.getMoisture())-256)*0.1304)); // 1023 pts (Dry) = 0%
743743
} // 256 pts = 100%
744744
else{
745-
FinalMoisturePercentage = 50 + (givenPlant.getMoisture() * 0.1953); // 0 pts (wet) = 50%
745+
FinalMoisturePercentage = 50 + ((1023-givenPlant.getMoisture()) * 0.1953); // 0 pts (wet) = 50%
746746
}
747747

748748
return FinalMoisturePercentage;
@@ -798,11 +798,11 @@ protected double healthBarAlgoDevilsIvy(Plant givenPlant){ //specifically
798798
}
799799

800800

801-
if (givenPlant.getMoisture() >= 512){
802-
FinalMoisturePercentage = 100-((givenPlant.getMoisture()-512)*0.1953); // 1023 pts (Dry) = 0%
801+
if ((1023-givenPlant.getMoisture()) >= 512){
802+
FinalMoisturePercentage = 100-(((1023-givenPlant.getMoisture())-512)*0.1953); // 1023 pts (Dry) = 0%
803803
} // 512 pts = 100%
804804
else{
805-
FinalMoisturePercentage = givenPlant.getMoisture() * 0.1953; // 0 pts (wet) = 0%
805+
FinalMoisturePercentage = (1023-givenPlant.getMoisture()) * 0.1953; // 0 pts (wet) = 0%
806806
}
807807

808808
if (givenPlant.getLightIntensity() == 0){ // case uv = 0
@@ -828,11 +828,11 @@ protected double moistureSmileyDevilsIvy(Plant givenPlant){ //specifically
828828

829829
double FinalMoisturePercentage;
830830

831-
if (givenPlant.getMoisture() >= 512){
832-
FinalMoisturePercentage = 100-((givenPlant.getMoisture()-512)*0.1953); // 1023 pts (Dry) = 0%
831+
if ((1023-givenPlant.getMoisture()) >= 512){
832+
FinalMoisturePercentage = 100-(((1023-givenPlant.getMoisture())-512)*0.1953); // 1023 pts (Dry) = 0%
833833
} // 512 pts = 100%
834834
else{
835-
FinalMoisturePercentage = givenPlant.getMoisture() * 0.1953; // 0 pts (wet) = 0%
835+
FinalMoisturePercentage = (1023-givenPlant.getMoisture()) * 0.1953; // 0 pts (wet) = 0%
836836
}
837837

838838
return FinalMoisturePercentage;
@@ -844,7 +844,7 @@ protected double tempSmileyDevilsIvy(Plant givenPlant){ //specifically for
844844

845845
if (givenPlant.getTemperature() >= 23){
846846
FinalTemperaturePercentage = 100-((givenPlant.getTemperature()-23)*4.3478); // 46 deg C = 0%
847-
} // 23 deg C = 100%
847+
} // 23 deg C = 100%
848848
else{
849849
FinalTemperaturePercentage = givenPlant.getTemperature() * 4.3478; // 0 deg C = 0%
850850
}
@@ -891,11 +891,11 @@ protected double healthBarAlgoSpider(Plant givenPlant){ //specifically for
891891
FinalTemperaturePercentage = givenPlant.getTemperature() * 4.3478; // 0 deg C = 0%
892892
}
893893

894-
if (givenPlant.getMoisture() >= 256){
895-
FinalMoisturePercentage = Math.abs(100-((givenPlant.getMoisture()-256)*0.1304)); // 1023 pts (Dry) = 0%
894+
if ((1023-givenPlant.getMoisture()) >= 256){
895+
FinalMoisturePercentage = Math.abs(100-(((1023-givenPlant.getMoisture())-256)*0.1304)); // 1023 pts (Dry) = 0%
896896
} // 256 pts = 100%
897897
else{
898-
FinalMoisturePercentage = 50 + (givenPlant.getMoisture() * 0.1953); // 0 pts (wet) = 50%
898+
FinalMoisturePercentage = 50 + ((1023-givenPlant.getMoisture()) * 0.1953); // 0 pts (wet) = 50%
899899
}
900900

901901
if (givenPlant.getLightIntensity() == 0){ // case uv = 0
@@ -920,11 +920,11 @@ else if (givenPlant.getLightIntensity()==4) {
920920
protected double moistureSmileySpider(Plant givenPlant){ //specifically for Sansevieria
921921
double FinalMoisturePercentage;
922922

923-
if (givenPlant.getMoisture() >= 256){
924-
FinalMoisturePercentage = Math.abs(100-((givenPlant.getMoisture()-256)*0.1304)); // 1023 pts (Dry) = 0%
923+
if ((1023-givenPlant.getMoisture()) >= 256){
924+
FinalMoisturePercentage = Math.abs(100-(((1023-givenPlant.getMoisture())-256)*0.1304)); // 1023 pts (Dry) = 0%
925925
} // 256 pts = 100%
926926
else{
927-
FinalMoisturePercentage = 50 + (givenPlant.getMoisture() * 0.1953); // 0 pts (wet) = 50%
927+
FinalMoisturePercentage = 50 + ((1023-givenPlant.getMoisture()) * 0.1953); // 0 pts (wet) = 50%
928928
}
929929

930930
return FinalMoisturePercentage;

0 commit comments

Comments
 (0)