Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. public with sharing class WeekThreeHomework {
  2.  
  3.  
  4. public static void homeworkAssignmentMethod() {
  5. //Read through the set-up below and then complete the code following the prompts. When you're done, make sure to compile (save) your work
  6. //Open Execute Anonymous in the Developer Console and execute your code by typing in: WeekThreeHomework.homeworkAssignmentMethod();
  7. //Read through the debug statements to make sure you're done your work correctly.
  8.  
  9. //************************************************************************************************************
  10.  
  11. // 1. Add two more whole numbers to this list using .add()
  12. List<Integer> numberList = new List<Integer>{ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
  13. numberList.add(55);
  14. numberList.add(89);
  15. //Checking our work:
  16. System.debug('This number should be 12: ' + numberList.size());
  17.  
  18. //************************************************************************************************************
  19. // 2. Create a new Lead and insert it in the database. (If you're stuck, look back at the WeekThreeClassExercises class for an example of creating a new SObject Record)
  20. //You can give it any values you like, but remember that last name and Company are required fields (both are simple text fields.)
  21. Lead newLead = new Lead();
  22.  
  23. newLead.FirstName = 'Sarah';
  24. newLead.LastName = 'Capps';
  25. newLead.Company = 'RAD Women';
  26. insert newLead;
  27.  
  28. //Checking our work:
  29. System.debug('We should see One DML was executed: ' + Limits.getDMLRows());
  30.  
  31.  
  32. //************************************************************************************************************
  33. //3. For the loop that is commented out below, update the while condition by replacing the ?? so that the loop runs 5 times
  34. //delete the slashes so that the loop is no longer commented out and compile the class.
  35.  
  36. //Can you add a debug statement to print out the counter value every time it runs through the loop?
  37.  
  38.  
  39. Integer counter = 0;
  40.  
  41. while (counter < 5) {
  42. System.debug('Loop Counter: ' + counter );
  43. counter++;
  44. }
  45.  
  46. System.debug('Done with the loop, it ran: ' + counter + ' times.');
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement