Created
September 15, 2017 21:08
-
-
Save pritaunk/9587d716417f235ae31835dd7899d87f to your computer and use it in GitHub Desktop.
PriyankaWeek2HW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class WeekTwoHomework { | |
public static void homeworkAssignmentMethod () { | |
//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 | |
//Open Execute Anonymous in the Developer Console and execute your code by typing in: WeekTwoHomework.homeworkAssignmentMethod(); | |
//Read through the debug statements to make sure you're done your work correctly. | |
//************************************************************************************************************ | |
// 1. Add two more whole numbers to this list using .add() | |
List < Integer > numberList = new List < Integer >{0,1,1,2,3,5,8,13,21,34}; | |
numberlist.add(78); | |
numberlist.add(4); | |
//Checking our work: | |
system.debug('This number should be 12: ' +numberList.size()); | |
//************************************************************************************************************ | |
// 2. Create a new Lead and insert it in the database. (If you're stuck, look back at the WeekTwoClassExercises class for an example of creating a new SObject Record) | |
//You can give it any values you like, but remember that last name and Company are required fields (both are simple text fields.) | |
//creating a new lead | |
lead l = new lead (); | |
l.LastName = 'Taunk'; | |
l.Company = 'Reevoo Ltd'; | |
insert l; | |
//Checking our work: | |
system.debug('We should see One DML was executed: '+ Limits.getDMLRows()); | |
//************************************************************************************************************ | |
//3. For the loop that is commented out below, update the while condition by replacing the ?? so that the loop runs 5 times | |
//delete the slashes so that the loop is no longer commented out and compile the class. | |
//Can you add a debug statement to print out the counter value every time it runs through the loop? | |
Integer counter = 0; | |
//while (counter < 5) { | |
counter++; //without this line to increment counter, we'd have an infinite loop! | |
System.debug('Done with the loop, it ran: ' + counter + ' times.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment