Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Flowers
- {
- static Scanner sc= new Scanner (System.in);
- String color;
- int height;
- int count=0;
- String address;
- static Perah[]Adanit= new Perah[10];
- public Flowers(String address){
- for (int i = 0; i < 10; i++) {
- System.out.println("Choose the height of the flower");
- this.height= sc.nextInt();
- System.out.println("What is the flower color?");
- sc.nextLine();
- this.color= sc.nextLine();
- Flowers.Adanit[i]=new Perah(color,height);
- }
- }
- /**
- * watering all the flowers
- * the boolean change to true while one of the flowers is dead
- */
- public void allFlowers(){
- for (int i = 0; i < Adanit.length; i++) {
- boolean dead=Adanit[i].watering();
- if(dead){
- count =count+1;
- }
- }
- if (count<6){
- count=0;
- }
- }
- /**
- *
- * @return, the action returns the number of the dying flowers.
- */
- public boolean mostAreDead(){
- if(count>=6){
- return true;
- }
- else{
- return false;
- }
- }
- public String getColor(){
- return color;
- }
- public static void main(String[] args) {
- System.out.println("Where do you want to place your planter?");
- String address= sc.nextLine();
- Flowers Flowers= new Flowers(address);
- int count=0;
- while(count<6){
- Flowers.allFlowers();
- boolean mostDead=Flowers.mostAreDead();
- if(mostDead){
- System.out.println("most of the flowers in "+Flowers.address+" are dead. You should buy new flowers");
- System.out.println("There are"+ Flowers.Adanit.length + "flowers in the planter");
- System.out.print("The flowers colors are: ");
- for (int j=0;j<Adanit.length;j++){
- System.out.println(Flowers.Adanit[j].getColor());
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement