Description Write a BASH shell script that simulates the drawing of double-six dominoes from a pool of dominoes Here are the comments in the professor\'s solution the describe the program and its functionality: # This is a BASH shell script that simulates drawing dominoes # from a single pool of \"double six\" dominoes # Double six dominoes are dominoes that range from blank (0) # to 6, with two values on each domino There are no duplicate # dominoes. Using a notation in which the value on each side # of the domino is separated by a pipe (1) symbol, the entire # set of double six dominoes co nsists of the follow ing dominoes: # 010 011 012 013 014 015 016 212 213 214 215 216 313 314 315 316 414 415 416 515 516 616 # The indentation of the domino es doesn\'t have any real meaning and # only serves to better show the number of dom inoes with each number. # The BASH shell script should check the numbe r of parameters on the # command line. If there are no parameters on the command line, # the BASH shell script should randomly select 6 dominoes from the pool # of possible dominoes and print tho se dominoe s out to the screen # in the order they were \"drawn\". The same dom ino cannot be drawn # more than once # If there is a single parameter on the command line, the BASH shell # script should read that value in as the number of dominoes to be # drawn. If that number is negative or that number is greater than # 28 (the maximum number of dom inoes), the BASH she 11 script should # display an error and exit. Otherwise, the BASH shell script should # draw the specified numbe r of dominoes , printing them to the screen # in the order drawn. Again, there should be no duplicates. The BASH # shells script should ens ure the provided parameters is a number. # If there are two parameters on the command line, the first parameter # should specify the numbe r of dominoes to be drawn as specified in the # previous paragraph. The second paramete r is the name of a file that # should be overw ritten if it already exists or created if it doe s not # yet exist. The dominoes as they are drawn should be output to this file # in addition to printing them to the screen in the order drawn # This BASH shell script should be well docume nted and clear written # using meaningful va riable names and clear structure
import java.util.*;
public category ArrayListExample i am attending to add String
*elements therefore I created it of string kind */
ArrayList<String> obj = new ArrayList<String>();
/*This is however components ought to be value-added to the array list*/
obj.add(\"Ajeet\");
obj.add(\"Harry\");
obj.add(\"Chaitanya\");
obj.add(\"Steve\");
obj.add(\"Anuj\");
/* Displaying array list components */
System.out.println(\"Currently the array list has following elements:\"+obj);
/*Add part at the given index*/
obj.add(0, \"Rahul\");
obj.add(1, \"Justin\");
/*Remove components from array list like this*/
obj.remove(\"Chaitanya\");
obj.remove(\"Harry\");
System.out.println(\"Current array list is:\"+obj);
/*Remove part from the given index*/
obj.remove(1);
System.out.println(\"Current array list is:\"+obj);
}
}
Output:
Currently the array list has following elements:[Ajeet, Harry, Chaitanya, Steve, Anuj]
Current array list is:[Rahul, Justin, Ajeet, Steve, Anuj]
Current array list is:[Rahul, Ajeet, Steve, Anuj]
Methods of ArrayList category
In the on top of example we\'ve got used ways like add and take away. but there square measure range of ways accessible which may be used directly exploitation object of ArrayList category. Let’s discuss few of the necessary ways.
1) add( Object o): This methodology adds Associate in Nursing object o to the arraylist.
obj.add(\"hello\");
This statement would add a string how-do-you-do within the arraylist ultimately position.
2) add(int index, Object o): It adds the item o to the array list at the given index.
obj.add(2, \"bye\");
It will add the string bye to the 2d index (3rd position because the array list starts with index 0) of array list.
3) remove(Object o): Removes the item o from the ArrayList.