In JAVA please
The "Emoji_List.txt" file contains a list of emojis that were introduced in 2017.
This is the list of the emojis 1. Grinning Face With One Large and One Small Eye 2. T-Rex 3. Man Zombie 4. Woman Zombie 5. Merman 6. Mermaid 7. Shocked Face With Exploding Head 8. Sandwich 9. Person With Headscarf 10. Flying Saucer 11. Giraffe Face 12. Breast-Feeding 13. Cricket 14. Serious Face With Symbols Covering Mouth 15. Woman Mage 16. Man Mage 17. Brain 18. Woman Vampire 19. Man Vampire 20. Grinning Face With Star Eyes 21. Broccoli 22. Sauropod 23. Man Fairy 24. Woman Fairy 25. Bearded Person 26. Palms Up Together 27. Woman Genie 28. Man Genie 29. Pretzel 30. Face With Monocle 31. Curling Stone 32. Man Elf 33. Woman Elf 34. Hedgehog 35. Cut of Meat 36. Woman Climbing 37. Man Climbing 38. Dumpling 39. Face With One Eyebrow Raised 40. Woman in Lotus Position 41. Man in Lotus Position 42. Wales 43. Face With Finger Covering Closed Lips 44. Face With Open Mouth Vomiting 45. Coconut 46. Scotland 47. Man in Steamy Room 48. Woman in Steamy Room 49. Takeout Box 50. Chopsticks 51. Smiling Face With Smiling Eyes and Hand Covering Mouth 52. Child 53. Adult 54. Older Adult 55. England 56. Fortune Cookie 57. Zebra Face 58. I Love You Hand Sign 59. Pie 60. Billed Cap 61. Canned Food 62. Gloves 63. Bowl With Spoon 64. Coat 65. Cup With Straw 66. Sled 67. Scarf 68. Socks 69. Orange Heart
Java Code: (Save as Driver.java)
import java.io.*;
import java.util.*;
//Emoji class to store number and text
//and also the next and previous reference
class Emoji{
int number;
String text;
Emoji prev;
Emoji next;
Emoji(int number,String text){
this.number=number;
this.text=text;
}
}
class DoubleLinkedList{
Emoji head=null;
Emoji tail=null;
public void addEmoji(Emoji newEmoji) {
//If Linked list is empty
if(head == null) {
//head and tail then point to newEmoji
head = tail = newEmoji;
//head's prev will be null
head.prev = null;
//tail's next will be null
tail.next = null;
}
else {
//newEmoji will be added after tail
tail.next = newEmoji;
//newEmoji's previous will point to tail
newEmoji.prev = tail;
//newEmoji will become the new tail
tail = newEmoji;
//As it is last Emoji, tail's next will be null
tail.next = null;
}
}
public void displayEmoji() {
//Emoji p will point to head
Emoji p = head;
if(head == null) {
System.out.println("Linekd List is empty");
return;
}
System.out.println("Emoji of doubly linked list: ");
while(p != null) {
//Prints each emoji
System.out.println(p.number + ". "+p.text);
p = p.next;
}
}
void selectionSort() {
Emoji p = head;
// traverse the Linked List
while (p!=null) {
Emoji min = p;
Emoji r = p.next;
// traverse unsorted sub Linked List
while (r!=null) {
if (min.text.compareTo(r.text)>0)
min = r;
r = r.next;
}
// Swap Data
String temp = p.text;
p.text = min.text;
min.text = temp;
p = p.next;
}
}
}
public class Driver {
public static void main(String args[]) throws Exception{
//create double list for Emoji class
DoubleLinkedList list = new DoubleLinkedList();
//open the Emoji_List file
File file = new File("Emoji_List.txt");
Scanner sc = new Scanner(file);
//while the file has new Line
while(sc.hasNextLine()){
//Split a line into two i.e number and string
String data[] = sc.nextLine().split(". ",2);
//System.out.println(data[1]);
//data[0] will be the number
//data[1] will be the correspoding text
Emoji newEmoji = new Emoji(Integer.parseInt(data[0]),data[1]);
//add the emoji in the linked list
list.addEmoji(newEmoji);
}
//sort the list using selection sort
list.selectionSort();
//display the emoji list
list.displayEmoji();
sc.close();
}
}
Output( comment below the code )
Emoji of doubly linked list:
1. Adult
2. Bearded Person
3. Billed Cap
4. Bowl With Spoon
5. Brain
6. Breast-Feeding
7. Broccoli
8. Canned Food
9. Child
10. Chopsticks
11. Coat
12. Coconut
13. Cricket
14. Cup With Straw
15. Curling Stone
17. Cut of Meat
18. Dumpling
19. England
20. Face With Finger Covering Closed Lips
21. Face With Monocle
22. Face With One Eyebrow Raised
23. Face With Open Mouth Vomiting
24. Flying Saucer
25. Fortune Cookie
26. Giraffe Face
27. Gloves
28. Grinning Face With One Large and One Small Eye
29. Grinning Face With Star Eyes
30. Hedgehog
31. I Love You Hand Sign
32. Man Climbing
33. Man Elf
34. Man Fairy
35. Man Genie
36. Man Vampire
37. Man Zombie
38. Man in Lotus Position
39. Man in Steamy Room
40. Mermaid
41. Merman
42. Older Adult
43. Orange Heart
44. Palms Up Together
45. Person With Headscarf
46. Pie
47. Pretzel
48. Sandwich
49. Sauropod
50. Scarf
51. Scotland
52. Serious Face With Symbols Covering Mouth
53. Shocked Face With Exploding Head
54. Sled
55. Smiling Face With Smiling Eyes and Hand Covering Mouth
56. Socks
57. T-Rex
58. Takeout Box
59. Wales
60. Woman Climbing
61. Woman Elf
62. Woman Fairy
63. Woman Genie
64. Woman Mage 16. Man Mage
65. Woman Vampire
66. Woman Zombie
67. Woman in Lotus Position
68. Woman in Steamy Room
69. Zebra Face
**KINDLY SAVE THE Link_List.txt file in new Line format
In JAVA please The "Emoji_List.txt" file contains a list of emojis that were introduced in 2017....