Professional Documents
Culture Documents
Find Study Resources: Answered Step-By-Step
Find Study Resources: Answered Step-By-Step
North South University / CSE / CSE 215 / Plant Flower extends Plant name: String h
Plant Flower extends Plant name: String hasSmell: boolean color: String hasThorn: boolean /* constructor * / /
* constructor */ /* accessor-mutator */ /* accessor-mutator */ /* toString */ tostring */ Herb extends Plant
isMedicinal: boolean season: String * constructor * / /* accessor-mutator * / * toString */
Java code
public class Plant {
public Plant() {}
this.name = name;
this.color = color;
this.hasSmell = hasSmell;
}
public class Herb extends Plant {
this.season = season;
}
public class inMain{
display(objects);
System.out.println("remove B");
remove(objects,"B");
display(objects);
System.out.println("add D");
display(objects);
plants[size]=p;
size++;
}
if(plants[i].getname() == n )
plants[i]=plants[i+1];
}
size--;
}
if(plants[i].getname() == n ){
temp = plants[i];
}
}
return temp;
System.out.println(plants[i]);
}
}
Step-by-step explanation
steps of solution
create class plant and its attributes and getter method ,tostring and constructor
public class Plant {
public Plant() {}
this.name = name;
this.color = color;
create class ower and its attributes and getter method ,tostring and constructor
public class Flower extends Plant {
this.hasSmell = hasSmell;
create class herb and its attributes and getter method ,tostring and constructor
public class Herb extends Plant {
this.season = season;
create main method and implement the methods add , remove , search and display
public class inMain{
display(objects);
System.out.println("remove B");
remove(objects,"B");
display(objects);
System.out.println("add D");
display(objects);
plants[size]=p;
size++;
}
if(plants[i].getname() == n )
plants[i]=plants[i+1];
}
size--;
}
if(plants[i].getname() == n ){
temp = plants[i];
}
}
return temp;
System.out.println(plants[i]);
}
}
output
Name A , Color red
Name B , Color blue
Name C , Color white
remove B
Name A , Color red
Name C , Color white
add D
Name A , Color red
Name C , Color white
Name D , Color yellow
Add to library
솩 솩
솩 솩 솩 솩
Company Get Course Hero Careers