Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Micah_Wu/.DS_Store
Binary file not shown.
Binary file added Micah_Wu/angular/.DS_Store
Binary file not shown.
34 changes: 34 additions & 0 deletions Micah_Wu/angular/bikes_OOP.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Bike {
constructor(
public price: number,
public max_speed: string,
public miles = 0)
{}
displayInfo = () => {
var bike = `${this.price} ${this.max_speed} ${this.miles}`;
console.log(bike);
return this;
}
ride = () => {
console.log('riding');
this.miles += 10;
return this;
}
reverse = () => {
if(this.miles>5){
this.miles -= 5
}
else{
this.miles = 0
}
return this;
}
}

let bike1 = new Bike(200, "25mph");
let bike2 = new Bike(300, "30mph");
let bike3 = new Bike(150, "15mph");

bike1.ride().ride().ride().ride().reverse().displayInfo()
bike2.ride().ride().reverse().reverse().displayInfo()
bike3.reverse().reverse().reverse().displayInfo()
139 changes: 139 additions & 0 deletions Micah_Wu/angular/debug_typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//1
var myString: string;
// I can assign myString like this:
myString = "Bee stinger";
// Why is there a problem with this? What can I do to fix this?
myString = 9;

var myString: string;
myString = "Bee stinger";
var myNumber: number;
myNumber = 9; //it is a number and not a string and a new variable with a type "number" must be created.
//or myString = "9";

//2
function sayHello(name: string){
return `Hello, ${name}!`;
}
// This is working great:
console.log(sayHello("Kermit"));
// Why isn't this working? I want it to return "Hello, 9!"
console.log(sayHello(9));
//console.log(sayHello("9")); Just make it a string.

//3
function fullName(firstName: string, lastName: string, middleName: string){
//function fullName(firstName: string, lastName: string, middleName?: string){ (add a question mark as optional parameter)
let fullName = `${firstName} ${middleName} ${lastName}`;
return fullName;
}
// This works:
console.log(fullName("Mary", "Moore", "Tyler"));
// What do I do if someone doesn't have a middle name?
console.log(fullName("Jimbo", "Jones"));


//4
interface Student {
firstName: string;
lastName: string;
belts: number;
}
function graduate(ninja: Student){
return `Congratulations, ${ninja.firstName} ${ninja.lastName}, you earned ${ninja.belts} belts!`;
}
const christine = {
firstName: "Christine",
lastName: "Yang",
belts: 2
}
const jay = {
firstName: "Jay",
lastName: "Patel",
belts: 4 //belts not belt
}
// This seems to work fine:
console.log(graduate(christine));
// This one has problems:
console.log(graduate(jay));

//5
class Ninja {
fullName: string;
constructor(
public firstName: string,
public lastName: string){
this.fullName = `${firstName} ${lastName}`;
}
debug () {
console.log("Console.log() is my friend.")
}
}
const shane = new Ninja("tom","jerry"); //added new before Ninja & arguments inside of Ninja
const turing = {
fullName: "Alan Turing",
firstName: "Alan",
lastName: "Turing",
debug(){ //added a debug function like class Ninja so that argument in function study would have same parameters.
console.log("Console.log() is my friend.")
}
}
function study(programmer: Ninja){
return `Ready to whiteboard an algorithm, ${programmer.fullName}?`
}
console.log(study(turing));


//6
var increment = x => x + 1;
// This works great:
console.log(increment(3));
var square = x => {x * x};
// This is not showing me what I want:
console.log(square(4));
// This is not working:
var multiply = x,y => x * y;
// Nor is this working:
var math = (x, y) => let sum = x + y;
let product = x * y;
let difference = Math.abs(x-y);
return [sum, product, difference];

var increment = x => x + 1;
console.log(increment(3));
var square = x => x * x; //removed {} for square function
console.log(square(4));
var multiply = (x,y) => x * y; //added () on x,y arguments
var math = (x, y) => { //added {} to contain math function
let sum = x + y;
let product = x * y;
let difference = Math.abs(x - y);
return [sum, product, difference];
}

//7
class Elephant {
constructor(public age: number){}
birthday = function(){
this.age++;
}
}
const babar = new Elephant(8);
setTimeout(babar.birthday, 1000)
setTimeout(function(){
console.log(`Babar's age is ${babar.age}.`)
}, 2000)
// Why didn't babar's age change? Fix this by using an arrow function in the Elephant class.


class Elephant {
constructor(public age: number){}
birthday = () => { //removed function and wrote it the es6 way
this.age++; //now this.age becomes a parameter of class Elephant
}
}
const babar = new Elephant(8);
setTimeout(babar.birthday, 1000)
setTimeout(function(){
console.log(`Babar's age is ${babar.age}.`)
}, 2000)
Binary file added Micah_Wu/angular/express_template/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions Micah_Wu/angular/express_template/angular-app/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
39 changes: 39 additions & 0 deletions Micah_Wu/angular/express_template/angular-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
27 changes: 27 additions & 0 deletions Micah_Wu/angular/express_template/angular-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# AngularApp

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.8.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
127 changes: 127 additions & 0 deletions Micah_Wu/angular/express_template/angular-app/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular-app:build"
},
"configurations": {
"production": {
"browserTarget": "angular-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"angular-app-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "angular-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "angular-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "angular-app"
}
Loading