Java Help Arrays/ArrayLists
Anybody know how to complete this assignment? I am completely lost haha.
Any help would be greatly appreciated :)
Mrs. Montez and Mr. Mufasa have decided to combine their classes in a joint project. To do this they will form partners with one student from Mrs. Montezâ€™s class paired with one student from Mr. Mufasaâ€™s. The students in Mrs. Montezâ€™s class are Troy, Gabriella, Sharpay, Ryan, Chad, Taylor, and Kelsi. The students in Mr. Mufasaâ€™s class are Simba, Scar, Nala, Pumbaa, Timon, Rafiki, and Zazu. They formed partners in the following way: They lined each of their classes up in the previous listed order. Then Mrs. Montez took her first student in line, Troy, and had Mr. Mufasa randomly choose one of his students. That student would then switch places in line with the first student so that the first students in each line would be partners. Then Gabriella would be randomly paired with a student who was moved to the second spot in Mr. Mufasaâ€™s line. This is repeated until the last person in Mrs. Montezâ€™s line is paired with the last person in Mr. Mufasaâ€™s line. You are to write a program which will make the pairs and print them out. To do this you will need to write a Partners class with the following specs:
â€¢ Two private instance variables:
o String students which is an array which holds the names of Mrs. Montezâ€™s students.
o ArrayList lions which holds the names of the students in Mr. Mufasaâ€™s class.
â€¢ A constructor.
â€¢ A method public void readInClasses() which puts the names of the students in both classes into the appropriate array.
â€¢ A method private void swap(int i, int j) which switches the ith student in Mr. Mufasaâ€™s line with the jth student in line.
â€¢ A method public void findPartner(int i) which randomly finds a partner for the ith student in Mrs. Montezâ€™s line and moves that person in Mr. Mufasaâ€™s line to the correct spot. .Donâ€™t worry if you pick the same random number twice or more. Just go ahead and make the switch.
â€¢ A method public void matchStudents() which matches each student (using a loop) in Mrs. Montezâ€™s class with a student in Mr. Mufasaâ€™s class.
â€¢ A method public void printPartners() which prints out the partners as in the example below:
Troy - Zazu
Gabriella - Simba
Sharpay - Rafiki
Ryan - Pumbaa
Chad - Scar
Taylor - Nala
Kelsi - Timon
Press any key to continue...
Your program must run with the provided PartnersTest class. You may not make any changes to this class. Whenever possible, use method calls in your code. Do not rewrite code.