Skip to content

Instantly share code, notes, and snippets.

View ECMessina's full-sized avatar

ECMessina

  • 23:50 (UTC -04:00)
View GitHub Profile
@ECMessina
ECMessina / main.dart
Last active July 19, 2023 19:48
Arguments
/* Arguments/parameters are values passed into a function
* two kinds of A/p's are accepted in functions (Positional and Named)
* function then uses those values to carry out provided instructions
* (display on screen, use in a calculation, or send to another function)
*
* add is Positional required
* addTwo is Named optional
* addThree is Positional optional
* addFour is Named with default values
* addFive is Named parameters required
@ECMessina
ECMessina / main.dart
Last active July 18, 2023 19:58
Angela's Love Score
import 'dart:math';
void main() {
loveCalculator();
}
// if (condition) {instruction();}
// else {instruction();}
// == means is or is equal to
// != not equal to
@ECMessina
ECMessina / main.dart
Created July 18, 2023 19:24
Angela's Love Score
void main() {
}
// if (condition) {instruction}
// == means is or is equal to
@ECMessina
ECMessina / main.dart
Last active July 18, 2023 20:10
Angela's Human
void main() {
// jenny is the new object
Human jenny = Human(startingHeight: 15, weight: 3.5);
// .height accessing height property
// this object.get this property
print(jenny.height);
jenny.height = 20;
print(jenny.height);
// .talk triggers the talk method
@ECMessina
ECMessina / main.dart
Last active July 18, 2023 20:53
Angela's Tesla
void main() {
// Object = new version of that class();
Car normalCar = Car();
print(normalCar.numberOfSeats);
normalCar.drive();
ElectricCar coCo = ElectricCar();
coCo.drive();
coCo.rechargeBattery();
LevitatingCar aLevitatingCar = LevitatingCar();
aLevitatingCar.drive();
@ECMessina
ECMessina / main.dart
Last active July 17, 2023 22:08
Big Nums
/*
*Create a list of integers and generate the two largest out of that list.
Integer: a whole number (not fractional) that can be positive, negative, or zero
Requirements:
Print out what the two largest are inside of the function to start with.
The List<int> that you pass in can be of any length, but not null
(List<int>? type would be nullable)
Do not use sort()
The largest and second largest cannot be the same number
If list were to change, consider nulls and print a statement for each scenario in main()
@ECMessina
ECMessina / main.dart
Last active July 16, 2023 20:41
Name Me
/*
Create list of Names
make a variable that is equal to what the user inputs in order to find that name
Create a function that returns a list of names
Parameters must reference the list and what the user inputs
To check the names within the list you'll need a for in loop
That loop will need an empy list to store any matches
account for caplitalization
- if user messes up be prepared by allowing the loop to automatically make sense of all letters
-uppercase or lowercase
@ECMessina
ECMessina / main.dart
Last active July 16, 2023 20:57
Basic Math
/*
Make a list containing 4, 5, & 6 (integers) and name it
Both requests ask to look for an object within a list, so for loops are needed for both
void needs to be return type for sum as you're printing in the function and not returning anything
return type of product function should be int (before the name of the function)
as you need to return to main to print,
also need to wrap in {} to make the parameter named
print and returns go outside of the loop
sum must start with 0 in order to account for the first number
same logic for product, but must be 1 or all the values will be 0
@ECMessina
ECMessina / main.dart
Last active July 16, 2023 21:09
Prime Time
/*
Create a variable that stores an integer that the user provides
completing a repetitive task means using a for loop
simple - so it can stay within main() - but can make a function if preferred
Prime Number is a whole number greater than 1 that cannot be divided by any whole number
other than itself and 1
Since 1 is valid, the initial check must start at 2 and go up from there
- can add by one as you can check all numbers in between
if statement with modulo will help determine if it is divisible by user given number
- if it is then it's not prime so set that if statement to say false
@ECMessina
ECMessina / main.dart
Last active July 16, 2023 21:13
Fizzle
/*
All within main() to keep the requirements together
must go through each number out of a bunch that's not in a list, so a for loop is best
the count starts at one so it initializes on that number
each number between must be analyzed including the last (100)
each time a number is analyzed in order
must use Modulo: returns the remainder of two integers when they are divided by each other
order is necessary for FizzBuzz
-it needs to print before any of the other words otherwise the wrong word would be printed
-once an if statement finds something true, it stops its cycle