Skip to content

Instantly share code, notes, and snippets.

@AngelOfCA
Created March 28, 2019 18:44
Show Gist options
  • Save AngelOfCA/eea7d28a448fb6ca41b39d41afdc15f7 to your computer and use it in GitHub Desktop.
Save AngelOfCA/eea7d28a448fb6ca41b39d41afdc15f7 to your computer and use it in GitHub Desktop.
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.
*/
//This class is used to calculate the Carts Value and ask if we are meeting the minimum requiered value.
public static void cartValues() {
//Sets the minimum cart value to 50, this will be later used as a threshold to ensure we meet our task of filling the cart. We are using a variable and setting it to 50; later we will check to see if we are at or above 50
Integer minimumCartValue = 50;
//We have 3 items to put in the cart and 3 unique values to total up. We are telling the computer that we have 3 whole numbers and I have a name for each number that I want to referance later in my code
Integer itemA = 10;
Integer itemB = 20;
Integer itemC = 45;
//Here we are adding two items to the cart and telling the code to add the values together based on the pre assigned values above. The total of the to variables gives us the the last part to our logic test that will tell us if we met our goal of filling the cart.
Integer cartValue = itemA + itemB;
//We are asking if when we use the above two values, do we meet or exceed the minimum value we need to fill our cart. Cart Value is a variable that we have already said is the combination of value a and b. This will return true(yes) or false(no) and answer our question
Boolean cartMinimumMet = cartValue >= minimumCartValue;
//Here we are testing our code. This debug allows us to run our code in the dev console and ensure we have written everything correctly before moving out to the SF platform and testing on real records in our sandbox
System.debug('Have we reached the minimum: ' + cartMinimumMet);
//Here we are reasigning a new value to our variable. Now we are asking if we take the current calculation, and add the 3rd item from above, do we meet our goal?
cartValue = cartValue + itemC;
//Our true/false logicc test; asks "How about now?"
cartMinimumMet = cartValue >= minimumCartValue;
//Our debug that allows us to test our code and read the answer in the Dev Console
System.debug('How about now? : ' + cartMinimumMet);
}
}
@tugce
Copy link

tugce commented Apr 2, 2019

Indentation is a bit off for some lines. Also comments that do not fit into one screen should be multiline to prevent scrolling to right. Overall great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment