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 welcome { | |
//Welcome! I'm a comment and I'm here to tell you what this particular class file is for. The developer who created this class added | |
//me so that future developers, like yourself, would have a quick little introduction to what this class does. | |
//The two little slashes tell the compiler* that everything following on this line is a note | |
//for humans and not code that needs to be executed | |
// (* A compiler is the computer program that translates this code into executable computer instructions) | |
//But you know what? This set of comments is already several lines long and getting longer. I'm tired of typing two slashes every time |
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 WeekOneHomework { | |
public static void introToPrimitives() { | |
//Primitives are the simplest elements in a programming language | |
/* A selection of primitives in Apex: | |
Integer: A number that does not have a decimal point, like 1 or 789 or -34 | |
Decimal: A number that includes a decimal point like 1.34 or 456.78907654 |
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 CommentingOnCodeExercise { | |
//Your Assignment is to add comments describing what is being done in the methods below. | |
//Call out the concepts you learned in your readings and in class. | |
public static void cartValues () { | |
// a variable called minimumCartValue has been declared and assigned a value of 50. | |
integer minimumCartValue = 50; | |
//declaring variables itemA, itemB and itemC and assigning values respectively. |
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. | |
//************************************************************************************************************ |
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 WeekThreeHomework { | |
//Let's practice calling different methods by writing our very own methods. You will write and save methods in the space below | |
//that call the existing methods you see already written here. Ready? Let's Go! | |
//Sample: Here is a public method that calls the getfavoriteColorsMethod below and prints the results to our debug log | |
public static void printOutFavoriteColorsDemo () { | |
List < String > favoriteColors = getFavoriteColors(); | |
system.debug('Here are the favorite colors: '+ favoriteColors); |
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 class StringArrayTest { | |
//The Apex class must be called 'StringArrayTest' and be in the public scope. (done) | |
//The Apex class must have a public static method called 'generateStringArray'. (done) | |
//The 'generateStringArray' method must return an array (or list) of strings. (done) | |
public static list <string> generateStringArray (integer n){ | |
list<string> thislist = new list<string>(); | |
for (integer i=0 ; i<10;i++) { | |
thislist.add('Test ' + i); | |
system.debug(thislist[i]); | |
} |
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 WeekFourHomework { | |
public static void setsReview(){ | |
//Your assignment: Play with Sets! | |
// 1. Create a set of Strings and add at least 5 entries | |
Set <string> SetofAccounts = new set <string> (); | |
SetofAccounts.add ('Canon'); |
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
//The first line of our trigger gives the Trigger's name (AccountTrigger), names the object (Account) and lists the trigger_events that will cause the code below to execute | |
//For example, "before insert" indicates that before an account record (or records) is inserted, the trigger will be called. | |
//For more information on trigger syntax: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_syntax.htm | |
trigger AccountTrigger on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) { | |
//Each section of code below handles a different event & timing combination. For now, we are demonstrating a trigger that has all of the logic right here. | |
//Later on we'll be looking at other ways of handling Trigger events using handler classes, but for now, we want to keep all the logic in once place as | |
//we're learning. |
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
//*REQUIREMENT 1* Before a Stock Item can be created, check that there is not already | |
// a stock item record with a matching name. | |
//the below creates the new stockitems in a set that | |
//doesn't allow for duplicates. Trigger.new to ensure all new records created | |
//for this object get added to this Set | |
set <string> stockitems = new set <string> (); | |
for (stock_item__c stock : trigger.new) { | |
stockitems.add(stock.Item_Name__c); |
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
//*DATA SET UP*created sample records using DML via the execute annonymous window | |
//stock_item__c stock = new stock_item__c (); | |
//stock.Item_Name__c = 'chocolate'; | |
//stock.description__c = 'i love chocolate'; | |
//stock.minimum_stock_level__c = 10; | |
//stock.stock_on_hand__c = 10; | |
//stock.list_price__c = 50; | |
//insert stock; | |
OlderNewer