1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Illusion [34]
3 years ago
6

LAB: Plant information (ArrayList) Given a base Plant class and a derived Flower class, complete main() to create an ArrayList c

alled myGarden. The ArrayList should be able to store objects that belong to the Plant class or the Flower class. Create a method called printArrayList), that uses the printinfo methods defined in the respective classes and prints each element in myGarden. The program should read plants or flowers from input (ending with -1), adding each Plant or Flower to the myGarden ArrayList, and output each element in myGarden using the printinfo method Ex. If the input is: plant Spirea 10 flower Hydrangea 30 false lilac flower Rose 6 false white plant Mint 4 -1 the output is: Plant Information: Plant name: Spirea Cost: 10 Plant Information: Plant name: Hydrengea Cost: 30 Annual: false Color of flowers: lilac Microsoft Edge Plant Information: Plant name: Hydrengea Cost: 30 Annual: false Color of flowers: lilac Plant Information: Plant name: Rose Cost: 6 Annual: false Color of flowers: white Plant Information: Plant name: Mint Cost: 4 LAB ACTIVITY 9.18.1: LAB: Plant information (ArrayList) 10/10 Current file: PlantArrayListExample.java Load default template... 1 import java.util.Scanner; 2 import java.util.ArrayList; 3 import java.util.StringTokenizer; 4 5 public class PlantArrayListExample { 6 7 // TODO: Define a PrintArrayList method that prints an ArrayList of plant (or flower) objects 8
Computers and Technology
1 answer:
sashaice [31]3 years ago
4 0

Answer:

LAB: Plant information (ArrayList) Given a base Plant class and a derived Flower class, complete main() to create an ArrayList called myGarden. The ArrayList should be able to store objects that belong to the Plant class or the Flower class. Create a method called printArrayList), that uses the printinfo methods defined in the respective classes and prints each element in

You might be interested in
Haigy Paigy is as a children's invented language which sounds exactly like English, except that "aig" is inserted before the vow
Aleksandr-060686 [28]

Answer:

def haigyPaigy(dict, text):

 # Create a regular expression  from the dictionary keys

 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))

 # For each match, look-up corresponding value in dictionary

 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)  

text = input("Enter text: ")

dict = {

   "a" : "aiga",

   "e" : "aige",

   "i" : "aigi",

   "o" : "aigo",

   "u" : "aigu",

   

 }  

print(haigyPaigy(dict, text))

Explanation:

Step 1:

define the haigyPaigy function: this function takes its argument from a dictionary and the text you you want to convert.

<em>def haigyPaigy(dict, text): </em>

<em />

In the function, there are two regular expressions:

  • <em>regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys()))) </em>

<em>this is a regular expression for the dictionary keys, it looks through the text for a match, it acts like a scanner, simply put, it looks for [a,e,i,o,u].</em>

re.compile(pattern, repl, string): is used to combine a regular expression pattern into pattern objects, which can be used for pattern matching. It also helps to search a pattern again without rewriting it.

  • <em>return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)  </em>

For each match, it looks up the key in the dictionary and replaces it with a corresponding value.

Step 2:

prompt the user to input the text that needs conversion to Haigy Paigy

<em>text = input("Enter text: ") </em>

Step 3:

Create the dictionary by inputting the key and the corresponding value.

NOTE: the key is what you want to replace in the text and the value is what you're replacing it with.

<em>dict = { </em>

<em>    "a" : "aiga", </em>

<em>    "e" : "aige", </em>

<em>    "i" : "aigi", </em>

<em>    "o" : "aigo", </em>

<em>    "u" : "aigu", </em>

<em>     </em>

<em>  }  </em>

<em />

Step 4:

Call the function and print the translated text to your screen.

<em>print(haigyPaigy(dict, text))</em>

<em />

8 0
3 years ago
Hugh is giving an informative speech about U.S. Senate election campaigns. Which thesis statement do you recommend he use?
34kurt
I recommend that he use this thesis statement :

<em>Candidates often use television advertising while campaigning for election to the senate, because television reaches millions of people and thus the ability to dramatically increase name recognition</em>
5 0
3 years ago
Write a program that will input two numbers and print the larger number on the screen.
Stella [2.4K]

num1 = float(input("Enter the first number: "))

num2 = float(input("Enter the second number: "))

if num1 > num2:

   print(num1)

else:

   print(num2)

I hope this helps!

8 0
3 years ago
How exactly do I answer questions?
pshichka [43]

Answer:

If you mean this website, click the add answer button on the question

Explanation:

8 0
2 years ago
Which is the last step in conducting a url research
tino4ka555 [31]
<span> The user's browser renders the html code as a visual web page. I think. Let me know if I git it wrong! :P</span>
6 0
4 years ago
Other questions:
  • In an open computer network such as the internet, hipaa requires the use of _____. in a closed system such as a local area netwo
    7·1 answer
  • After a new technology is purchased,what are some additional costs that must be incorporated into an upgrade budget?
    6·1 answer
  • 22 If you are involved in a violation and you do not have insurance to comply with the __________________, your driver license a
    9·2 answers
  • What kind of music you guys play
    5·2 answers
  • A common practice is to create a(n) _____ on any field that is used as a search key, in comparison operations in a conditional e
    6·1 answer
  • Weak Induction
    8·1 answer
  • What is the most likely reason that a digital artist would use a program such as Autodesk Maya or Max to create 3-D images for a
    12·1 answer
  • How to Calculate the area of a rectangle in python
    13·2 answers
  • Which of the following events happened first
    15·2 answers
  • Which types of online reading tools are available within the CloseReader? Check all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!