Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1.  
  2.  
  3. 2 of 12,086
  4. mgm technology partners USA Corp | Next Steps
  5. Inbox
  6. x
  7.  
  8. Kylee Honig | mgm technology partners <kylee_honig@mgmtp.recruiterbox.com>
  9. Attachments
  10. Wed, Oct 16, 3:21 PM (18 hours ago)
  11. to allison.coopersmith
  12.  
  13. Dear Allison,
  14.  
  15. Thanks for taking the time to chat with me today about the Junior Software Developer (Java) role. Here's the Java code sample I mentioned on the phone. Please correct and streamline the information and send it back to me within the next three business days.
  16.  
  17. Feel free to reach out if you have any questions!
  18.  
  19. My best,
  20. Kylee Honig
  21.  
  22.  
  23.  
  24.  
  25.  
  26. Attachments area
  27.  
  28. Allison Coopersmith
  29. Attachments8:47 AM (57 minutes ago)
  30. Good morning Kylee, I was really excited by our conversation yesterday and want to get moving towards next steps, so I decided to do the coding assignment last
  31.  
  32. Kylee Honig | mgm technology partners
  33. 8:51 AM (53 minutes ago)
  34. to allison.coopersmith
  35.  
  36. Hi Allison!
  37.  
  38. Thank you for getting this back to me. I will pass it along to one of our Senior Developers and get back to you within a week.
  39.  
  40. I look forward to speaking with you soon!
  41.  
  42. Best,
  43. Kylee Honig
  44.  
  45. Sounds great, thank you!Great, thank you so much!Sounds great!
  46.  
  47. import java.util.Arrays;
  48.  
  49. //Your task is to:
  50. //- fix the code
  51. //- improve the poor quality of this code.
  52. //
  53. // (You can change anything you want
  54. //
  55. //The class should sort food instances and output the following lines:
  56. //
  57. //Potato 1
  58. //Potato 9
  59. //Potato 11
  60. //Tomato 11
  61. //Potato 12
  62. //Potato 42
  63. //Potato 46
  64. //Potato 55
  65. //Potato 77
  66. //Tomato 121
  67. //
  68.  
  69. public class MgmInterviewFoodSort {
  70.  
  71. public FOOD[] potatoes = null;
  72.  
  73. public abstract class FOOD {
  74. public int size = -1;
  75.  
  76. public String whoAMI() {
  77. return this.getClass().getName()
  78. .substring(MgmInterviewFoodSort.class.getName().length() + 1);
  79. }
  80. }
  81.  
  82. public class Potato extends FOOD {
  83. //
  84. }
  85.  
  86. public class Tomato extends FOOD {
  87. // default size for tomato
  88. public int size = 121;
  89. }
  90.  
  91. public void main() {
  92.  
  93.  
  94. // sort food
  95. final FOOD[] SORTEDFOOD = new FOOD[10];
  96. for (int i = 0; i < 10; i++) {
  97. final int index_of_the_smaller_food=i;
  98. for (int j = i; j < 10; j++) {
  99. if(potatoes[index_of_the_smaller_food].size > potatoes[j].size){
  100. index_of_the_smaller_food=j;
  101. }
  102. if(potatoes[index_of_the_smaller_food].size == potatoes[j].size && potatoes[index_of_the_smaller_food].whoAMI().contains("Tomato")){
  103. index_of_the_smaller_food=j;
  104. }
  105. }
  106. SORTEDFOOD[i]=potatoes[index_of_the_smaller_food];
  107. potatoes[index_of_the_smaller_food]=potatoes[i];
  108. }
  109.  
  110. //print result
  111. for (final FOOD potato : Arrays.asList(SORTEDFOOD)) {
  112. System.out.println(potato.whoAMI() + " " + potato.size);
  113. }
  114. }
  115.  
  116. public static void main(final String[] args) {
  117.  
  118. MgmInterviewFoodSort fs=new MgmInterviewFoodSort();
  119.  
  120. potatoes = new FOOD[10];
  121. final Tomato p0 = fs.new Tomato();
  122. p0.size = 11;
  123. potatoes[0] = p0;
  124. final Tomato p1 = fs.new Tomato();
  125. potatoes[1] = p1;
  126.  
  127. final Potato p2 = fs.new Potato();
  128. p2.size = 1;
  129. potatoes[2] = p2;
  130. final Potato p3 = fs.new Potato();
  131. p3.size = 42;
  132. potatoes[3] = p3;
  133. final Potato p4 = fs.new Potato();
  134. p4.size = 77;
  135. potatoes[4] = p4;
  136. final Potato p5 = fs.new Potato();
  137. p5.size = 55;
  138. potatoes[5] = p5;
  139. final FOOD p6 = fs.new Potato();
  140. p6.size = 46;
  141. potatoes[6] = p6;
  142. final FOOD p7 = fs.new Potato();
  143. p7.size = 12;
  144. potatoes[7] = p7;
  145. final Potato p8 = fs.new Potato();
  146. p8.size = 11;
  147. potatoes[8] = p8;
  148. final Potato p9 = fs.new Potato();
  149. p9.size = 9;
  150. potatoes[9] = p9;
  151.  
  152. fs.main();
  153. }
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement