Question: GETTING ERROR: Cannot find symbol - Class LinkedList import java.util.*; //Plant.java class Plant{ String name; int id; String color; Plant(){ } void SetID(int id) {

GETTING ERROR: "Cannot find symbol - Class LinkedList"

import java.util.*; //Plant.java class Plant{ String name; int id; String color; Plant(){ } void SetID(int id) { this.id = id; } int GetID() { return this.id; } void SetName(String name) { this.name = name; } void SetColor(String color) { this.color = name; } public void Show(){ System.out.println("ID:"+id+" Name:"+name+" Color:"+color); } } //Flower.java class Flower extends Plant{ String thorns; String smell; void SetSmell(String smell) { this.smell = smell; } void SetThorns(String thorn) { this.thorns = thorn; } public void Show(){ super.Show(); System.out.println("thorns:"+thorns+"Smell:"+smell); } } //Fungus.java class Fungus extends Plant{ boolean poisonous; void SetPoisonous(boolean poisonous) { this.poisonous = poisonous; } public void Show(){ super.Show(); System.out.println("poisonous:"+poisonous); } } //Weed.java class Weed extends Plant{ boolean poisonous; String edible; String medicinal; void SetPoisonous(boolean poisonous) { this.poisonous = poisonous; } void SetEdible(String edible) { this.edible = edible; } void SetMedicinal(String medicinal) { this.medicinal = medicinal; } public void Show(){ super.Show(); System.out.println("poisnous:"+poisonous+"edible:"+edible+"medicinal:"+medicinal); } } //Mid.java public class Mid{ static LinkedList plants; public static Plant SearchPlant(int id) { for(Plant p:plants){ if ( p.GetID() == id ) { return p; } } return null; } public static void main(String []args){ plants=new LinkedList (); boolean continueChoice = false; Scanner scanner = new Scanner(System.in); int choice = 0; do { try{ System.out.println("Choose Plant:1. Flower 2. Fungus 3.Weed Enter Option:"); int plantCh = scanner.nextInt(); if ( plantCh < 1 || plantCh > 3 ) { System.out.println("Wrong Choice Entered! Try Again"); continue; } System.out.println("Choose Operation:1. Add 2. Remove 3. Search 4. Show Enter Option:"); int op = scanner.nextInt(); switch(op) { case 1://Add int id; System.out.println("Enter ID:"); id = scanner.nextInt(); scanner.nextLine(); //This is needed to pick up the new line System.out.println("Enter Name:"); String name = scanner.nextLine(); System.out.println("Enter Color:"); String color = scanner.nextLine(); Plant p = null; if ( plantCh == 1 ) { p = new Flower(); System.out.println("Enter thorns:"); String thorns = scanner.nextLine(); ((Flower)p).SetThorns(thorns); // p.SetThorns(thorns); System.out.println("Enter Smell:"); String smell = scanner.nextLine(); ((Flower)p).SetSmell(smell); } else if(plantCh == 2 ) { p = new Fungus(); System.out.println("Enter poisnous:"); boolean poison = scanner.nextBoolean(); ((Fungus)p).SetPoisonous(poison); } else { p = new Weed(); System.out.println("Enter poisnous:"); boolean poison = scanner.nextBoolean(); ((Weed)p).SetPoisonous(poison); System.out.println("Enter Edible:"); String edible = scanner.nextLine(); ((Weed)p).SetEdible(edible); System.out.println("Enter Medicinal:"); String medicinal = scanner.nextLine(); ((Weed)p).SetMedicinal(medicinal); } p.SetID(id); p.SetName(name); p.SetColor(color); plants.add(p); break; case 2://Remove { System.out.println("Enter Plant ID:"); id =scanner.nextInt(); Plant plantOBJ = SearchPlant(id); if ( plantOBJ != null ) { plants.remove(plantOBJ); System.out.println("Flower ID: "+id+"removed"); } else { System.out.println("Flower ID: "+id+"not found"); } } break; case 3://Search System.out.println("Enter Plant ID:"); id =scanner.nextInt(); if ( SearchPlant(id) != null ) { System.out.println("Flower ID: "+id+"found"); } else { System.out.println("Flower ID: "+id+"not found"); } break; case 4://Show { System.out.println("Enter Plant ID:"); id =scanner.nextInt(); Plant plantObj = SearchPlant(id); if ( SearchPlant(id) != null) { plantObj.Show(); } else { System.out.println("Flower ID: "+id+"not found"); } } break; default: System.out.println("Wrong choice"); } System.out.print("Do you want to continue (true or false): "); continueChoice = scanner.nextBoolean(); } catch(Exception e) { e.printStackTrace(); } } while(continueChoice); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!