Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ziada-js-oop-class-15 #168

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0709ec8
update mhd ziada pesudo code
mohamadziada Apr 9, 2021
815cb82
solve HTML Practice Mohamad Ziada
mohamadziada Apr 9, 2021
11e6376
update HTML Practice
mohamadziada Apr 10, 2021
4b8674c
delete the class-1 solutions to submit pesudo code
mohamadziada Apr 10, 2021
89d8477
update class-1
mohamadziada Apr 11, 2021
0d91e44
Merge branch 'class-1'
mohamadziada Apr 11, 2021
14e9820
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 11, 2021
e51bc41
solve the blogPage
mohamadziada Apr 11, 2021
09457ce
update class-2
mohamadziada Apr 13, 2021
cb5a624
change class one folder name
mohamadziada Apr 13, 2021
8b193b0
delete .ds-store file
mohamadziada Apr 13, 2021
4495b76
delete ds-store
mohamadziada Apr 13, 2021
38414d3
.DS_Store removed
mohamadziada Apr 13, 2021
b7d971f
.DS_Store removed
mohamadziada Apr 13, 2021
89078b8
resloving merge issue
mohamadziada Apr 21, 2021
15f0740
resolve merge conflict for class-2
mohamadziada Apr 21, 2021
28e0016
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 21, 2021
77e07d6
commiting intro js class4 mustafa & ziada
mohamadziada Apr 21, 2021
698fe8b
commit all class4 activities
mohamadziada Apr 21, 2021
2ec1e83
ziada & mustafa class 4 if function
mohamadziada Apr 21, 2021
8b2f2e1
ziada-mustafa-js-if-conditions update
mohamadziada Apr 21, 2021
a93567c
if condition ziada-mustafa and js intro ziada-nidal of class4
mohamadziada Apr 21, 2021
37bfd55
sperating the activites of class 4 into branches
mohamadziada Apr 21, 2021
70d867b
ziada & ali riza solution class 5
mohamadziada Apr 21, 2021
136953a
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 23, 2021
c0adeef
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 23, 2021
33affff
ziada and mustafa js-dom-and-array
mohamadziada Apr 23, 2021
98dcc28
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 25, 2021
791ef77
ziada and isa claculator and madlibs
mohamadziada Apr 25, 2021
f51eb27
update folder name to ziada-isa
mohamadziada Apr 26, 2021
841e9ad
Merge branch 'class-6'
mohamadziada Apr 30, 2021
71aeb3b
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada Apr 30, 2021
933066d
ziada and deniz scope activity
mohamadziada Apr 30, 2021
5465f16
remove scope activity from main due to previous opened PR
mohamadziada Apr 30, 2021
404bf9c
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 2, 2021
aa25c67
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 11, 2021
efdf362
pull upstream
mohamadziada May 19, 2021
e4b8b4f
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 19, 2021
93f7533
update
mohamadziada May 19, 2021
2dae3cb
Merge branch 'main' of https://github.com/ReCoded-Org/bootcamp-turkey…
mohamadziada May 22, 2021
1edf54e
my solution to wheres waldo - no partner due to absent
mohamadziada May 22, 2021
d3415d3
commit class15 activities
mohamadziada May 23, 2021
89f3ba1
remove class 14
mohamadziada May 23, 2021
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
Binary file removed .DS_Store
Binary file not shown.
38 changes: 38 additions & 0 deletions class-15-js-OOP/ziada/minesweeper/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const input = [
[0, 0, 9, 9],
[9, 0, 9, 0],
[0, 9, 9, 0],
[9, 9, 9, 0]

]

function count(data, i, j) {
let counter = 0;

const prevRow = data[i - 1];
const currentRow = data[i]
const nextRow = data[i + 1];

[prevRow, currentRow, nextRow].forEach(row => {
if (row) {
if (row[j - 1] === 9) {counter++};
if (row[j] === 9) {counter++};
if (row[j + 1] === 9) {counter++};
}
})
console.log(counter)
return counter;
}

count(input)

function update(data) {
return data.map((row, i) => {
return row.map((colCell, j) => {
return colCell == 9 ? colCell : count(data, i, j)
})
})
}

const result = update(input)
console.log(result)
33 changes: 33 additions & 0 deletions class-15-js-OOP/ziada/minesweeper/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Minesweeper Number of Neighbouring Mines

Create a function that takes an array representation of a Minesweeper board, and returns another board where the value of each cell is the amount of its neighbouring mines.


### Notes:

- Since in the output the numbers 0-8 are used to determine the amount of adjacent mines, the number 9 will be used to identify the mines instead.
- A wikipedia page explaining how Minesweeper works is available in the Resources tab.



### Examples

[
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 1, 0, 1],
[1, 1, 0, 0],
]

The 0 represents an empty space . The 1 represents a mine.
You will have to replace each mine with a 9 and each empty space with the number of adjacent mines, the output will look like this:

[
[1, 9, 2, 1],
[2, 3, 9, 2],
[3, 9, 4, 9],
[9, 9, 3, 1],
]


Solution
68 changes: 68 additions & 0 deletions class-15-js-OOP/ziada/oop-car-demo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class Car {
// Part 1. Constructor (REVIEW)
constructor(color, fuelType) {
this.color = color;
this.fuelType = fuelType;
}

// Method.
paint(newColor) {
return this.color = newColor;
}

// Part 2. Static methods.
hasTheSameProperties(car2){
return this.color === car2.color &&
this.fuelType === car2.fuelType
}

static hasTheSamePropertiesStatic(car1, car2) {
return car1.color === car2.color &&
car1.fuelType === car2.fuelType
}


// Part 3. Getter, setter.
get speedKmH() {
return this.speed
}

get speedInKmSec(){
return this.speedKmH/3600
}

set speedKmH(newTopSpeedKmH) {
if (newTopSpeedKmH > 300) {
throw new Error ('Speed must be less than 300');
} else {
this.speed = newTopSpeedKmH
}
}

get speedInMiles() {
return this.speed * 0.621371
}


static compareSpeed(car1, car2) {
if (car1.speed > car2.speed) {
return car1
} else {
return car2
}
}
}

const audi = new Car("red","gas")
const tesla = new Car('red', "electric")

audi.paint('blue')

audi.speedKmH = 230
// we call getter without paranthies
console.log(audi.speedKmH)

console.log(audi.speedInKmSec)


console.log(audi.hasTheSameProperties(tesla))
Binary file removed class-3/.DS_Store
Binary file not shown.