Initial Commit
This commit is contained in:
commit
c90b3a95fe
55
CS2 - Demo/Main.java
Normal file
55
CS2 - Demo/Main.java
Normal file
@ -0,0 +1,55 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/*
|
||||
CS2 Demo
|
||||
|
||||
System.out and System.in
|
||||
This demo goes over how to write and read text
|
||||
from the console so that we can have some basic input and
|
||||
output from our Java program
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//System.out.println is used when you want
|
||||
//to put some text into the console when your program is
|
||||
//running. A lot of the time, you'll see the first
|
||||
//programming example your trying to learn is
|
||||
//a "Hello World!" example. System.out.println
|
||||
//is one of many ways that you can output text
|
||||
//to the console
|
||||
System.out.println("Hello World!");
|
||||
|
||||
System.out.println("This is console out!");
|
||||
|
||||
//A Scanner is used together with System.in to collect
|
||||
//text, numbers, true and false values, etc. from users
|
||||
//of your program. While Scanner is not the only
|
||||
//way of interacting with System.in, it's one of the
|
||||
//more straightforward ways
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
//Notice that we use System.out.print and System.out.println
|
||||
//here, the difference is one moves the text cursor to the
|
||||
//next line after writing the text you asked for (println)
|
||||
//and one doesn't (print)
|
||||
System.out.print("Write some text: ");
|
||||
|
||||
//Scanner.nextLine() can be used to capture text
|
||||
//from the user. Below, we combine some already written
|
||||
//text with whatever the user ends up typing in. The nice
|
||||
//thing about Scanner.nextLine() is that the program
|
||||
//won't move forward until the user hits Enter on the
|
||||
//keyboard
|
||||
System.out.println("You wrote: " + scan.nextLine());
|
||||
|
||||
//Some resources, like Scanner, need to be closed. This
|
||||
//"frees" the resource so that it's available for another part
|
||||
//of this program (or another program running on the computer)
|
||||
//to access it. In this case, because we're at the end of our
|
||||
//program, closing Scanner isn't really necessary, but it's
|
||||
//a good practice to get into, because there are some resources
|
||||
//that need to be closed before your program finishes, otherwise
|
||||
//you may "break" that resource for other programs.
|
||||
scan.close();
|
||||
}
|
||||
}
|
92
CS2 - Demo/README.md
Normal file
92
CS2 - Demo/README.md
Normal file
@ -0,0 +1,92 @@
|
||||
# 2022 Training - CS2 - Demo
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://gitlab.coldlightalchemist.com/brad95411/2022-training-cs2-demo.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://gitlab.coldlightalchemist.com/brad95411/2022-training-cs2-demo/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
83
CS3 - Demo/Main.java
Normal file
83
CS3 - Demo/Main.java
Normal file
@ -0,0 +1,83 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/*
|
||||
CS3 Demo
|
||||
|
||||
Variables and Basic Math
|
||||
This demo goes over how to store values in variables.
|
||||
These values can be predefined in your code, come from
|
||||
mathematical and other types of operations, or be collected
|
||||
from the user in some way. This demo also covers general
|
||||
math operations in Java
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
//Below are some examples of program defined variables. Variables
|
||||
//that you would set up in your code, and use elsewhere. There are 4 different
|
||||
//types of variables here, all capable of storing different things.
|
||||
//String = Text, int = Whole Numbers, double = decimal (real) numbers, boolean = true/false
|
||||
//These are common variable types that you'll use in every Java program, but
|
||||
//there are many other types of variables. Scanner, as we have also seen, is
|
||||
//a type of variable.
|
||||
//Notice the yellow lines under the variable names, this is just VSCode letting
|
||||
//us know that the variables we've defined are never used, and therefore not needed
|
||||
//They are here only for an example
|
||||
String someString = "Some string value";
|
||||
int lifeUniverseEverything = 42;
|
||||
double someDouble = 2.22;
|
||||
boolean bananasAreGood = true;
|
||||
|
||||
//Below are several examples on how to retrieve different types of values from the
|
||||
//user. Strings, ints, booleans, and doubles can be grabbed using there appropriate
|
||||
//method, nextLine for Strings, nextInt for ints, nextBoolean for booleans, and
|
||||
//nextDouble for doubles. Each of these values are stored separately and then
|
||||
//reprinted down below to the user.
|
||||
//Notice how we can use the plus sign to combine other data types with Strings
|
||||
//to be printed. Java is smart enough to know that those values need to be
|
||||
//converted to String in order to combine properly. Just be careful, there
|
||||
//are scenarios were this won't work.
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.print("Enter a string: ");
|
||||
String string = scan.nextLine();
|
||||
|
||||
System.out.print("Enter a integer: ");
|
||||
int intValue = scan.nextInt();
|
||||
|
||||
System.out.print("Enter a true/false value: ");
|
||||
boolean booleanValue = scan.nextBoolean();
|
||||
|
||||
System.out.print("Enter a double value: ");
|
||||
double doubleValue = scan.nextDouble();
|
||||
|
||||
System.out.println("The values you entered");
|
||||
System.out.println("String: " + string);
|
||||
System.out.println("Integer: " + intValue);
|
||||
System.out.println("Boolean: " + booleanValue);
|
||||
System.out.println("Double: " + doubleValue);
|
||||
|
||||
//Below common math operations are displayed, you should be familiar with
|
||||
//addition, multiplication, subtraction, and division already. But you may
|
||||
//not be familiar with modulous or remainder operations (the % sign operation).
|
||||
//This divides two integers (NOT DOUBLES) and rather than return the division result
|
||||
//it returns the remainder, so rather than 5 / 3 = 1, you have 5 % 3 = 2
|
||||
//Notice that the math operations are encased in parenthesis inside the
|
||||
//call to System.out.println, this is done to ensure Java's automatic String combination
|
||||
//mechanism doesn't get confused, and that our math operations are performed
|
||||
//before trying to combine the result with the rest of the String.
|
||||
System.out.print("Enter the first double value: ");
|
||||
double firstNumber = scan.nextDouble();
|
||||
|
||||
System.out.print("Enter the second double value: ");
|
||||
double secondNumber = scan.nextDouble();
|
||||
|
||||
System.out.println("" + firstNumber + " + " + secondNumber + " = " + (firstNumber + secondNumber));
|
||||
System.out.println("" + firstNumber + " - " + secondNumber + " = " + (firstNumber - secondNumber));
|
||||
System.out.println("" + firstNumber + " * " + secondNumber + " = " + (firstNumber * secondNumber));
|
||||
System.out.println("" + firstNumber + " / " + secondNumber + " = " + (firstNumber / secondNumber));
|
||||
System.out.println("" + (int)firstNumber + " % " + (int)secondNumber + " = " + (((int)firstNumber) % ((int)secondNumber)));
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
61
CS4 - Demo/Main.java
Normal file
61
CS4 - Demo/Main.java
Normal file
@ -0,0 +1,61 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.print("Enter Int Value 1: ");
|
||||
int intValue1 = scan.nextInt();
|
||||
|
||||
System.out.print("Enter Int Value 2: ");
|
||||
int intValue2 = scan.nextInt();
|
||||
|
||||
if(intValue1 == intValue2) {
|
||||
System.out.println("Int Value 1 equals Int Value 2");
|
||||
} else {
|
||||
System.out.println("Int Value 1 does not equal Int Value 2");
|
||||
}
|
||||
|
||||
if(intValue1 > intValue2) {
|
||||
System.out.println("Int Value 1 is greater than Int Value 2");
|
||||
} else if(intValue1 < intValue2) {
|
||||
System.out.println("Int Value 1 is less than Int Value 2");
|
||||
} else {
|
||||
System.out.println("Int Value 1 is equal to Int Value 2");
|
||||
}
|
||||
|
||||
if(intValue1 < 100 && intValue1 > 50) {
|
||||
System.out.println("Int Value 1 is greater than 50 AND less than 100");
|
||||
} else {
|
||||
System.out.println("Int Value 1 is NOT greater than 50 AND less than 100");
|
||||
}
|
||||
|
||||
if(intValue2 < 25 || intValue2 > 50) {
|
||||
System.out.println("Int Value 2 is less than 25 OR greater than 50");
|
||||
} else {
|
||||
System.out.println("Int Value 2 is NOT less than 25 OR greater than 50");
|
||||
}
|
||||
|
||||
System.out.print("Enter String Value 1: ");
|
||||
String stringValue1 = scan.nextLine();
|
||||
|
||||
System.out.print("Enter String Value 2: ");
|
||||
String stringValue2 = scan.nextLine();
|
||||
|
||||
if(stringValue1.equals(stringValue2)) {
|
||||
System.out.println("String Value 1 is equal to String Value 2");
|
||||
} else if(stringValue1.equalsIgnoreCase(stringValue2)) {
|
||||
System.out.println("String Value 1 is equal to String Value 2 if you ignore case");
|
||||
} else {
|
||||
System.out.println("String Value 1 does not equal String Value 2");
|
||||
}
|
||||
|
||||
if(intValue1 != 42) {
|
||||
System.out.println("Int Value 1 does not equal 42");
|
||||
} else {
|
||||
System.out.println("Int Value 1 equals 42");
|
||||
}
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
59
CS5 - Demo/Main.java
Normal file
59
CS5 - Demo/Main.java
Normal file
@ -0,0 +1,59 @@
|
||||
import java.util.Random;
|
||||
|
||||
/*
|
||||
CS5 Demo
|
||||
|
||||
For Loops and Random Numbers
|
||||
This demo goes over how to write for loops and how
|
||||
there generally used. This demo also includes Java's
|
||||
Random class, so we can generate random values while using for
|
||||
loops.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//This for loop prints numbers from 0 through 9 (inclusive)
|
||||
//A for loop in this instance does what is known as "iterating"
|
||||
//over a series of values, in this case, we are iterating over
|
||||
//a range of numbers. In order to use a for loop in this way
|
||||
//we need to define three pieces inside the parenthesis
|
||||
//int i = 0; This first piece (initialization) defines
|
||||
//what value you are using to iterate your loop. This can
|
||||
//actually be left out (unlike the next two pieces) if you're
|
||||
//using a variable already defined elsewhere in your code
|
||||
//i < 10; This is your condition, what determines if the loop
|
||||
//should continue to run. So long as the variable i is < 10,
|
||||
//the loop runs.
|
||||
//i++ - This is our modifier, the thing that is changing to
|
||||
//ensure that at some point our loop will exit (and avoid an
|
||||
//infinite loop). i++ just means to add 1 to i. Each time the
|
||||
//loop finishes a run of whatever is inside the brackets, i++
|
||||
//will get called to update the value of i to i = i + 1;
|
||||
//For this loop, all we're doing is printing the value of
|
||||
//i as it changes while the loop runs.
|
||||
for(int i = 0; i < 10; i++) {
|
||||
System.out.println("Index Number: " + i);
|
||||
}
|
||||
|
||||
//Similar to Scanner, we can create other types of objects
|
||||
//and in this case, we are creating one called Random.
|
||||
//This just gives us access to a (pseudo) random value generator.
|
||||
//This wouldn't be good if you wanted truely random values, but
|
||||
//it'll serve out purposes well enough for now.
|
||||
Random random = new Random();
|
||||
|
||||
//With this for loop, we're trying to print 5 of each type of
|
||||
//primitive value (int, double, and boolean) that we've seen so
|
||||
//far. If all goes well, this will print the following for each
|
||||
//variable type
|
||||
//ValueName Value i+1: randomValue
|
||||
//Where ValueName is the current random value type we're trying to create
|
||||
//i is the current for loop i value
|
||||
//randomValue is the value generated by the Random object for
|
||||
//that specific type of variable.
|
||||
for(int i = 0; i < 5; i++) {
|
||||
System.out.println("Int Value " + (i + 1) + ": " + random.nextInt());
|
||||
System.out.println("Double Value " + (i + 1) + ": " + random.nextDouble());
|
||||
System.out.println("Boolean Value " + (i + 1) + ": " + random.nextBoolean());
|
||||
}
|
||||
}
|
||||
}
|
27
CS6 - Demo/Main.java
Normal file
27
CS6 - Demo/Main.java
Normal file
@ -0,0 +1,27 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
for(int i = 0; i < 10; i++) {
|
||||
if(i == 2 || i == 5) {
|
||||
continue;
|
||||
} else if(i == 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("For Index Number: " + i);
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while(counter < 10) {
|
||||
if(counter == 2 || counter == 5) {
|
||||
counter++;
|
||||
continue;
|
||||
} else if(counter == 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("While Index Number: " + counter);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
12
CS7 - Demo/Main.java
Normal file
12
CS7 - Demo/Main.java
Normal file
@ -0,0 +1,12 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Tree oakTree = new Tree("Oak", 10, .5); //Height and width are in whatever units you want
|
||||
Tree pineTree = new Tree("Pine", 25, 1.25);
|
||||
|
||||
System.out.println(oakTree);
|
||||
oakTree.grow(5, .5);
|
||||
|
||||
System.out.println(oakTree);
|
||||
System.out.println(pineTree);
|
||||
}
|
||||
}
|
32
CS7 - Demo/Tree.java
Normal file
32
CS7 - Demo/Tree.java
Normal file
@ -0,0 +1,32 @@
|
||||
public class Tree {
|
||||
private String typeOfTree;
|
||||
private double height;
|
||||
private double width;
|
||||
|
||||
public Tree(String newTypeOfTree, double newHeight, double newWidth) {
|
||||
typeOfTree = newTypeOfTree;
|
||||
height = newHeight;
|
||||
width = newWidth;
|
||||
}
|
||||
|
||||
public String getTypeOfTree() {
|
||||
return typeOfTree;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void grow(double heightAdd, double widthAdd) {
|
||||
height += heightAdd;
|
||||
width += widthAdd;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Type of Tree: " + typeOfTree + " Height: " + height + " Width: " + width;
|
||||
}
|
||||
}
|
BIN
CS8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.odp
Normal file
BIN
CS8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.odp
Normal file
Binary file not shown.
BIN
CS8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.pdf
Normal file
BIN
CS8 - Basic Robot Electronics/CS8 - Basic Robot Electronics.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user