Skip to content

Instantly share code, notes, and snippets.

@pritaunk
pritaunk / Week0homework.cls
Created August 31, 2017 18:38
Week0homework
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
@pritaunk
pritaunk / PriyankaWeekOneHomework.cls
Last active September 15, 2017 23:33
PTWeekonehomework
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
@pritaunk
pritaunk / PriyankaWeekOneCommenting.cls
Created September 13, 2017 20:41
Commenting on code week 1
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.
@pritaunk
pritaunk / PriyankaWeek2HW
Created September 15, 2017 21:08
PriyankaWeek2HW
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.
//************************************************************************************************************
@pritaunk
pritaunk / PriWeek3HW
Created September 19, 2017 19:26
Priyanka Week3homework
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);
@pritaunk
pritaunk / Week3homeworkPart2
Last active September 19, 2017 21:40
Week3 homework part 2
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]);
}
@pritaunk
pritaunk / PriWeek4hw
Created September 25, 2017 21:11
Week4homework
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');
@pritaunk
pritaunk / Week6hwpriyanka.cls
Created October 14, 2017 13:44
Week6hwpriyanka
//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.
@pritaunk
pritaunk / requirement1
Created October 22, 2017 17:58
Final Project Apex
//*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);
@pritaunk
pritaunk / datasetup.cls
Created October 22, 2017 17:58
Final Project Apex
//*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;