Posted: April 17th, 2020
Randomness and Array Manipulation
Assessment Brief
Question 1 - Randomness and array manipulationsYou are a promising junior programmer in a video game business. You are part of a team working on an online gaming system for a first-person shooter game. In the game, players can register to an arena to play together. Sometimes, they play solo; sometimes, they play in teams.A1_Q1.pdeYou have been asked to implement a set of functionalities in Processing (!) to be able to shuffle and make subgroups of players to play in teams.Each player is identified by its username (a String object).Start from this code: A1_Q1_Source.zip. The sketch declares empty methods that you need to implement (called "stubs"). It also contains a list of usernames on which it performs a series of tests. You can see the correct expected result of these tests here. If your functions are implemented correctly, you should get similar results. Note that the results of the last test may slightly vary since it involves randomness.A1_Q1.pde1a - Randomize listImplement the following method without using ArrayList (ie. using only arrays)./** * This method takes a list of usernames and randomizes it. * @param userNames the list of usernames * @return a new array containing the randomized list of usernames */String[] createShuffledList(String[] userNames) {}Important:There should be no repetitions in the usernames (unless there was a username twice in the list sent as a parameter).The returned list should contain all and only the items from the original list. This means that it will have the same length (among other things).The list of usernames sent as a parameter should not be modified (ie. be aware that you are passing by reference).1b - GroupingImplement the following method without using ArrayList (ie. using only arrays)./** * This method takes a list of usernames and separates them in different groups. * @param userNames the list of usernames * @param nGroups the number of groups * @return an array of groups of usernames */String[][] createGroups(String[] userNames, int nGroups) {}Example:String[] userNames = loadStrings("usernames.txt"); // you can define your own file with usernames for testing purposesStringp[][] groups = createGroups(list, 3);will return an array "groups" where groups[i][j] contains the j-th username of the i-th group. Another way to say it is that groups[i] is an array of String (ie. String[]) containing the usernames of its group.Important:If nGroups is smaller than 1, it should be considered equal to 1 (ie. one group with everyone in it).if nGroups is larger than the number of usernames in the list, it should be considered equal to the number of usernames (ie. one person per "group").If the list has length 0 or is null, the method should return null.The returned array length is equal to the number of groups ie. groups.length == nGroups.There should be no repetitions of usernames anywhere in the returned array and all usernames should be there.When the number of usernames sent as a parameter cannot be perfecly divided by nGroups, you will have to return a mix of groups of different sizes. When that happens:You need to make sure that the difference in size between two groups does not exceed 1. For example, if you call createGroups(list, 3), the result should be an array of groups where each group contains either 2 or 3 usernames.The bigger groups should be at the beginning of the returned array; the smaller groups at the end.Groups are formed sequentially, in the order of the elements found in userNames. So for instance, userNames[0] should appear in the first group and userNames[length-1] should always be in the last group.1c - Randomized groupsAdd an optional boolean to the last method: when true, the usernames will be randomized instead of being chosen sequentially./** * This method takes a list of usernames and separates them in different groups. * @param userNames the list of usernames * @param nGroups the number of groups * @param randomize if true, the groups will contain shuffled usernames; if false, the usernames will be added sequentially to the groups * @return an array of groups of usernames */String[][] createGroups(String[] userNames, int nGroups, boolean randomize) {}
Can I See Writer Credentials?
You can view anonymized writer profiles, highlighting their degrees and expertise, to feel confident in who is handling your paper. This transparency helps you choose the best fit for your needs. Each profile showcases years of experience and specialization areas for informed decision-making. Our team ensures every writer meets high academic standards. Assignment writer credentials include verified degrees and proven subject mastery.
Order | Check Discount
Tags: write my essay online, Thesis Help UK, Dissertation Writing Services, Cheap Essay Writing Service