Skip to content
Open

Algo #732

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .vscode/DodgeballCP/DCPindex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dodge Ball</title>
</head>
<body>
<div>
<h4>List Of People</h4>
<ul id="people"></ul>
</div>
<button onclick="listPeopleChoices()">List People</button>
<div>
<h4>Dodge Ball Players</h4>
<ul id="players"></ul>
</div>
<div>
<h4>Blue Team</h4>
<ul id="blue"></ul>
</div>
<div>
<h4>Red Team</h4>
<ul id="red"></ul>
</div>
<script src='DCPscript.js'></script>
</body>
</html>
175 changes: 175 additions & 0 deletions .vscode/DodgeballCP/DCPscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
'use strict'
const arrOfPeople = [
{
id: 2,
name: "Charles Young",
age: 55,
skillSet: "welding",
placeBorn: "Omaha, Nebraska"
},
{
id: 3,
name: "Judy Twilight",
age: 35,
skillSet: "fishing",
placeBorn: "Louisville, Kentucky"
},
{
id: 4,
name: "Cynthia Doolittle",
age: 20,
skillSet: "tic tac toe",
placeBorn: "Pawnee, Texas"
},
{
id: 5,
name: "John Willouby",
age: 28,
skillSet: "pipe fitting",
placeBorn: "New York, New York"
},
{
id: 6,
name: "Stan Honest",
age: 20,
skillSet: "boom-a-rang throwing",
placeBorn: "Perth, Australia"
},
{
id: 7,
name: "Mia Watu",
age: 17,
skillSet: "acrobatics",
placeBorn: "Los Angeles, California"
},
{
id: 8,
name: "Walter Cole",
age: 32,
skillSet: "jump rope",
placeBorn: "New Orleans, Louisiana"
},
]

const listOfPlayers = []
const blueTeam = []
const redTeam = []
// creating player class
class player {
constructor(name, age, skillSet){
this.name = name
this.age = age
this.skillSet = skillSet
this.placeBorn = this.placeBorn
}
// adding the class to the people of the array
addToArrayOfPeople() {
arrOfPeople.push(this)
}
}
// creating blue team class
class blueTeammate extends player {
constructor(name, age, skillSet, placeBorn, team){
super (name, age, skillSet, placeBorn);
this.team = team
this.color = blue
this.mascot = Sky
}
// adding the class and attributes to the people of the blue team array
joinTeam() {
if (this.team === 'blue') {
blueTeam.push(this.name)
}
}
}
// creating red team class
class redTeammate extends player {
constructor(name, age, skillSet, placeBorn, team,){
super (name, age, skillSet, placeBorn);
this.team = team
this.color = red
this.mascot = Tomato
}
// adding the class and attributes to the people of the red team array
joinTeam() {
if (this.team === 'red') {
redTeam.push(this.name)
}
}
}
const listPeopleChoices = () => {
const listElement = document.getElementById('people')
arrOfPeople.map(person => {
const li = document.createElement("li")
const button = document.createElement("button")
button.innerHTML = "Make Player"
button.addEventListener('click', function() {
makePlayer(person)
removeFromList(button)
})
li.appendChild(button)
li.appendChild(document.createTextNode(person.name + " - " + person.skillSet))
listElement.append(li)
})
}
//creating a function that removes people from the List People list
const removeFromList = (button) => {
const parentLi = button.parentElement
parentLi.remove()
}
// creating a function that removes people and buttons from the bodgeball players list
const removeFromSort = (li, redButton, blueButton) => {
li.remove()
redButton.remove()
blueButton.remove()
}
// creating a function that adds people to the red team and pushes the redTeam class and its attributes onto them by adding them to the redTeam array
const joinRed = (person) => {
const red = document.getElementById('red')
const li = document.createElement('li')
li.innerHTML = `${person.name}`
red.append(li)
redTeam.push(person.name)
}
// creating a function that adds people to the blue team and pushes the blueTeam class and its attributes onto them by adding them to the blueTeam array
const joinBlue = (person) => {
const blue = document.getElementById('blue')
const li = document.createElement('li')
li.innerHTML = `${person.name}`
blue.append(li)
blueTeam.push(person.name)
}

// creating players
const makePlayer = (player) => {
console.log(`li ${player.id} was clicked!`)
// finding people in the array who's id's match those of the people who were clicked
const person = arrOfPeople.find((p)=> {
console.log(p)
return p.id === player.id;
})
const listElement = document.getElementById("players")
const li = document.createElement('li')
li.appendChild((document.createTextNode(person.name + " - " + person.skillSet)))
listOfPlayers.push(player)
console.log('this is the new list of players', listOfPlayers)
// making a button for the red team that adds them to the red team when clicked
const redButton = document.createElement('button')
redButton.innerHTML = 'Red Team'
redButton.classList.add('red')
redButton.addEventListener('click', function() {
removeFromSort(li, redButton, blueButton)
joinRed(person)
})
// making a button for the blue team that adds them to the blue team when clicked
const blueButton = document.createElement('button')
blueButton.innerHTML = 'Blue Team'
blueButton.classList.add('blue')
blueButton.addEventListener('click', function() {
removeFromSort(li, blueButton, redButton)
joinBlue(person)
})
// adding the buttons to the ul
listElement.append(li,blueButton, redButton)
}

10 changes: 10 additions & 0 deletions .vscode/DodgeballCP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Overview:
We are in need of a sorting and organizing app for our community dodge ball league. There are already 6 players signed up and we hope to get more! We need to select from our currently sign-up people to make them dodge ball players and from there we need to be able to select them to be on different teams. Please look over the Specs Checklist to make sure you understand the needs of this app.

Starting out there is 4 arrays in the problem. One is the array of people we are given at the beginning, then there is the list of players array (which is empty), the blue team array (which is empty), and the red team array (which is empty).
Plan:
If you load the webpage the first time the only thing is a button that says list people, when you click it, it creates and populates the list of people and their skill set shown in the DOM. Clicking this will also create a 'Make Player' button next to each persons name.

My first step would be adding attributes to the different classes such as Player, and extending those attributes to the BlueTeammate and RedTeammate while also adding new attributes to the different teams such as color and mascot.

My second step to creating this program is going to be giving the make player function, functionality. We need a few things to happen when the button is clicked. When the button is clicked we need it to add the persons name to the dodgeball players list and create 2 buttons next to their name that say "red team" or "blue team" while also taking the original name and button away in the list of people list. Then behind the scenes, when the button is clicked we want to take the player off of the arrOfPeople array and add them to the list of players array. We need to add functionality to the Red Team and Blue Team buttons, so that when they are clicked it will then add the player to the corresponding team list in the DOM while also taking them and the two team buttons off the list of dodgeball players in the DOM. Again behind the scenes we need to make sure the player is added to the corresponding array for the team they are selected onto.
5 changes: 5 additions & 0 deletions .vscode/DodgeballCP/TEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1. Once a person is moved to the dodgeball players list in the DOM, console log the listOfPlayers array and open the console to see if the person was moved and if they have inherited the class 'Player' attributes.

2. Once a person is moved to the red team list in the DOM, console log the redTeammate array and open the console to see if the person was moved and if they have inherited the class 'redTeam' attributes.

3. Once a person is moved to theblue team list in the DOM, console log the blueTeammatearray and open the console to see if the person was moved and if they have inherited the class 'blueTeam' attributes.
10 changes: 10 additions & 0 deletions .vscode/random/scottie.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

</body>
</html>
2 changes: 2 additions & 0 deletions 01week/HelloWorld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict'
console.log('Hello World')
Empty file added 01week/conditionals.js
Empty file.
11 changes: 11 additions & 0 deletions 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ const rl = readline.createInterface({

// the function that will be called by the unit test below
const rockPaperScissors = (hand1, hand2) => {
let Hand1 = hand1.toLowerCase().trim();
let Hand2 = hand2.toLowerCase().trim();
if(hand1 === hand2) {
return "It's a tie!"
}
else if(Hand1 === "rock" && Hand2 === "scissors" || Hand1 === 'paper' && Hand2 === "rock" || Hand1 === 'scissors' && Hand2 === "paper"){
return "Hand one wins!"
}
else {
return "Hand two wins!"
}

// Write code here
// Use the unit test to see what is expected
Expand Down
28 changes: 26 additions & 2 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,33 @@ const rl = readline.createInterface({

const pigLatin = (word) => {

// Your code here
let str = word;
// Convert string to lowercase
str = str.toString().toLowerCase();
// Initialize array of vowels
const vowels = ["a", "e", "i", "o", "u"];
// Initialize vowel index to 0
let vowelIndex = 0;

if (vowels.includes(str[0])) {
// If first letter is a vowel
return str + "yay";
} else {
// If the first letter isn't a vowel i.e is a consonant
for (let char of str) {
// Loop through until the first vowel is found
if (vowels.includes(char)) {
// Store the index at which the first vowel exists
vowelIndex = str.indexOf(char);
break;
}
}
// Compose final string
return str.slice(vowelIndex) + str.slice(0, vowelIndex) + "ay";
}
}


}


const getPrompt = () => {
Expand Down
14 changes: 14 additions & 0 deletions 02week/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function longestString(sentence) {

let sentenceArr = sentence.trim().split(" ");
let longestCandidate = sentenceArr[0];
for (let i=0; i< sentenceArr.length; i++) {
let currentWord = sentenceArr[i];
if (currentWord.length > longestCandidate.length) {
longestCandidate = currentWord;
}
}
return longestCandidate;

}
console.log(longestString("The lazy dog jumped over the brown cow"));
23 changes: 23 additions & 0 deletions 03week/Towers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
let board = {
towerA: [],
towerB: [],
towerC: []
}


board.towerA.push(7);
board.towerC.push(4);
board.towerC.push(1);

let fromTower = board.towerA;
let toTower = board.towerC;

// get the last value of the object
let lastFrom = fromTower[fromTower.length-1];
let lastTo = toTower[toTower.length-1];

// move pieces
let poped = fromTower.pop();
toTower.push(poped);

console.log(board);
21 changes: 21 additions & 0 deletions 03week/todo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>The Best ToDo Tracker</h1>
<ul>
</ul>
<input type="text" id="inputText"> <button id='addButton'> add</button>
</input>
</body>
<style>
.done {
text-decoration: line-through;
}
</style>
<script src="todo.js"></script>
</html>
Loading