Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA 2 files seprate 1.Staff.java 2.StaffTester.java (provided) Use the following file: StaffTester.java import java.util.ArrayList; /** * Tester */ public class StaffTester { public static void

JAVA

2 files seprate

1.Staff.java

2.StaffTester.java (provided)

image text in transcribed

Use the following file:

StaffTester.java

import java.util.ArrayList; /** * Tester */ public class StaffTester { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add("Goodyear"); list.add("Sathyanantha"); list.add("Keomahavong"); list.add("Addison"); list.add("Smith"); ArrayList list2 = new ArrayList(); list2.add("^aeiouy$"); list2.add("^AEIOUY$"); Staff lister = new Staff(list); Staff lister2 = new Staff(list2); Staff empty = new Staff(new ArrayList()); //test an empty list lister.replaceVowelsWith("*"); System.out.println(lister); System.out.println("Expected: [G**d***r, S*th**n*nth*, K**m*h*v*ng, *dd*s*n, Sm*th]"); lister2.replaceVowelsWith("#"); System.out.println(lister2); System.out.println("Expected: [^######$, ^######$]"); empty.replaceVowelsWith("*"); System.out.println(empty); System.out.println("Expected: []"); //testing equals list.clear(); list.add("Goodyear"); list.add("Sathyanantha"); list.add("Keomahavong"); list.add("Addison"); list.add("Smith"); lister = new Staff(list); list2.clear(); list2.add("Goodyear"); list2.add("Sathyanantha"); list2.add("Keomahavong"); list2.add("Addison"); list2.add("Smith"); lister2 = new Staff(list2); System.out.println("equal?: " + lister.equals(lister2)); System.out.println("Expected: true"); list2.remove(list2.size() - 1); System.out.println("equal?: " + lister.equals(lister2)); System.out.println("Expected: false"); System.out.println("contains?: " + lister.sameContents(lister2)); System.out.println("Expected: false"); list2.add(1, "Smith"); System.out.println("contains?: " + lister.sameContents(lister2)); System.out.println("Expected: true"); list2.set(1, "smith"); System.out.println("equal?: " + lister.equals(lister2)); System.out.println("Expected: false"); System.out.println("equal?: " + empty.equals(empty)); System.out.println("Expected: true"); System.out.println(lister.mostVowels()); System.out.println("Expected: Keomahavong"); list.remove(2); System.out.println(lister.mostVowels()); System.out.println("Expected: Goodyear"); System.out.println(empty.mostVowels()); System.out.println("Expected: null"); } }
Wrte the class staff. It contains methods that manipulate an ArrayList ot Strings representing the names ot statt members. Ihe constructor takes an ArrayList of String names as a parameter. In addition to the constructor, you need to Implement the tollowing metnods The methads publi boolean equals (staff other - Determines If the other staff contains all the same elements in the same order as this staff * public boolean annecontents (Staff other:) -Determines lt the other staff and this start contain exactly the same elements but in any order .public void replaceVowelsHith(String ext) Replaces cach vow clement with the replaccment valuc text. Assume the vowels are aclouyAEIOUY . public string mostvouels) Gcts the staff mcmber whose name has the most owels. If more than one has that number of vowcls, return the first. Rcturn null if the list is empty. Assume the owls are acicuAEIOU el In every ArrayLlst pulic St.ring tostringe astring represent inn using Arrayl ist's toString method Wrte the class staff. It contains methods that manipulate an ArrayList ot Strings representing the names ot statt members. Ihe constructor takes an ArrayList of String names as a parameter. In addition to the constructor, you need to Implement the tollowing metnods The methads publi boolean equals (staff other - Determines If the other staff contains all the same elements in the same order as this staff * public boolean annecontents (Staff other:) -Determines lt the other staff and this start contain exactly the same elements but in any order .public void replaceVowelsHith(String ext) Replaces cach vow clement with the replaccment valuc text. Assume the vowels are aclouyAEIOUY . public string mostvouels) Gcts the staff mcmber whose name has the most owels. If more than one has that number of vowcls, return the first. Rcturn null if the list is empty. Assume the owls are acicuAEIOU el In every ArrayLlst pulic St.ring tostringe astring represent inn using Arrayl ist's toString method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions