Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Now that we\'ve helped apparently everyone on the planet make some money except

ID: 3836613 • Letter: N

Question

Now that we've helped apparently everyone on the planet make some money except ourselves it's time to move on. As we're leaving town a courier runs up to us to deliver a letter. It reads:

Dear Friends,

I hope this letter finds you well and in good spirits. The doctor has arrived and has begun treating Elizabeth for what he proclaims as a 'vicious infection'. Many of the plants that I've collected using your flower pack have gone to great use. Elizabeth was able to wiggle her toes this morning and regained a tingling sensation not long after... IT’S WORKING!

We truly appreciate all that you've done, and extend an open offer for you to stay with us whenever you would like. Although all of our birth family is gone, we truly consider you our only family.

Thanks again,

Alexander and Elizabeth

After hearing this great news we continue on our way. We can see our destination, the city of Thanto, off in the distance, but know that the toughest part of our journey still lies ahead. We have two major obstacles that could cause us anguish, but as always, we have a plan. Or at least we think we do. The first obstacle we must traverse is the North Woods and the second is Fraus River. First things first: we must find an escort through the North Woods if we want to make it through alive. The woods are dangerous and constantly painful as the air is dense and corrosive making breathing difficult.

As darkness approaches and we make our way towards the woods we notice a small fire burning not too far away at the forest edge. We head towards the camp and notice a middle aged woman sitting by the fire. After a brief introduction we find out that she plans to make her way through the woods tonight and knows the path of least resistance, but refuses to take us along. She refuses to give us her real name, only a nickname, Epi.

After some bargaining we convince Epi to take us along, under specific circumstances though. Epi wants to use our flower pack on the way through the woods to collect many different types of plants to determine which ones are causing the horrid state of the forest. After we make it through the forest with all of these plants she wants to run some tests on these plants. She believes it's a common element between these plants that is causing these issues. She would like us to determine a way to find all of these common elements.

The idea Epi has is that the name of the plant is determining how potent the poison is. She believes that the higher frequency of a letter in the name, the higher the potency.

Using our existing flower pack we must add the following feature:

Using recursion (no loops!) you must count the number of times a specific character, or set of characters appears in the name of each plant in your pack. We will call this 'analyzing' for the sake of future terminology. Examples are provided on the last page.

The following features are also required but should only be slightly changed from previous requirements.

You must have a graphical user interface implemented. This GUI MUST be unique but can be the same as you've previously used.

You must be able to display, add, remove, sort, filter, and now analyze information from our flower pack.

The flower pack should hold flowers, weeds, fungus, and herbs. All should be a subclass of a plant class.

Each subclass shares certain qualities (ID, Name, and Color) – in plant class

Flower traits include (Thorns and Smell)

Fungus traits include (Poisonous)

Weed traits include (Poisonous, Edible and Medicinal)

Herb traits include (Flavor, Medicinal, Seasonal)

Submit 6 files: Assignment6.java, flower.java, fungus.java, plant.java, weed.java, and herb.java

Explanation / Answer

import java.util.Vector;
public class Assignment6 {

//Displays the plants

public void display(){

// Prints the elements
System.out.println("The elements in the flowerpack are:");   
for (Plant plant : vec) {   
       System.out.println("Plant = " + plant.Name);
}

}   

//Adds a plant
public void add_plant(Plant pl, Vector vec){
       vec.add(pl);

}
  

//Removes a plant
   public void remove_plant(Plant pl, Vector vec){
       vec.remove(pl);

}
  
  
//Sorts the plants
   public void sort_plants(Vector vec){
       Collections.sort(vec);

}
  

//Analyzes the plants
       public int analyze_plants(char c, Vector vec){
               static int count = 0;
              
               for (Plant plant : vec) {   
                   String x = plant.Name;
                   if(x[1]!= NULL) analyze(plant.Name.substring(0), c, count);
               }
              

}
  
   public static int analyze(String s, char c, static int count){
       if(s[0] == NULL) return count;
       if(s[0] == c) count ++;
       if(s[1]!= NULL) analyze(s.substring(1), c, count);
  
   }
  
  
   public static void main(String[] args) {
       // create an empty Vector vec with an initial capacity of say, 10   
       Vector vec = new Vector(10);
Plant Plant("MoneyPlant", "Green", 1);
       this.add_plant(one, vec);
       this.display();
       Flower two = new Flower("Rose", "Pink", 2, true, true);
       this.add_plant(two, vec);
       this.sort_plants(vec);
       this.analyze_plants("v", vec);
       this.remove_plant(one,vec);

}
}


public class Plant {
private String Name;
private String Color;
private Integer ID;
public Plant(String Name, String Color, Integer ID) {
this.Name = Name;
this.ID = ID
this.Color = Color;
}
}

//Flower class, sub-class of Plant
public class Flower extends Plant {
private boolean Thorns;
private boolean Smell;

public Flower(String Name, String Color, Integer ID, boolean Thorns, boolean Smell){
super(Name, Color, ID);
this.Thorns = Thorns;
this.Smell = Smell;
}
}

//Fungus class
public class Fungus extends Plant {
private boolean Poisonous;
  

public Fungus(String Name, String Color, Integer ID, boolean Poisonous){
super(Name, Color, ID);
this.Poisonous = Poisonous;
}
}

//Weed class

public class Weed extends Plant {
private boolean Poisonous;
private boolean Edible;
provate boolean Medicinal;
  
public Weed(String Name, String Color, Integer ID, boolean Poisonous, boolean Edible, boolean Medicinal){
super(Name, Color, ID);
this.Poisonous = Poisonous;
this.Edible = Edible;
this.Medicinal = Medicinal;
}
}

//Herb class

public class Herb extends Plant {
private boolean Seasonal;
private String Flavor;
private boolean Medicinal;
  

public Herb(String Name, String Color, Integer ID, String Flavor, boolean Medicinal, boolean Seasonal){
super(Name, Color, ID);
this.Flavor = Flavor;
this.Seasonal = Seasonal;
this.Medicinal = Medicinal;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote