added doga
This commit is contained in:
parent
121b8365a9
commit
1784bc7fee
14
24_11_11_doga/Feladat1.html
Normal file
14
24_11_11_doga/Feladat1.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Feladat1</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Adatok az API-ból:</h1>
|
||||
<pre id="eredmeny"></pre>
|
||||
<script src="Feladat1.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
37
24_11_11_doga/Feladat1.js
Normal file
37
24_11_11_doga/Feladat1.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
let url = "https://jsonplaceholder.typicode.com/posts/1/comments";
|
||||
|
||||
async function adatlekeres(url) {
|
||||
try{
|
||||
let response = await fetch(url);
|
||||
if(!response.ok){
|
||||
throw new Error("HIBA, a response nem OK");
|
||||
} else{
|
||||
let data = await response.json();
|
||||
return data;
|
||||
}
|
||||
} catch{
|
||||
console.log("Hiba történt!");
|
||||
}
|
||||
}
|
||||
|
||||
function createDomElement(element) {
|
||||
let line = document.createElement("div");
|
||||
line.innerHTML = `ID: ${element.id}, Email: ${element.email}`;
|
||||
eredmeny.appendChild(line);
|
||||
}
|
||||
|
||||
async function selectSpecifiedData(dataset){
|
||||
dataset.forEach(element => {
|
||||
if (element.id == 1 || element.id == 3 || element.id == 5){
|
||||
createDomElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let eredmeny = document.getElementById("eredmeny");
|
||||
async function main(){
|
||||
let adatok = await adatlekeres(url);
|
||||
await selectSpecifiedData(adatok);
|
||||
}
|
||||
|
||||
main();
|
14
24_11_11_doga/Feladat2.html
Normal file
14
24_11_11_doga/Feladat2.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Feladat2</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Adatok az API-ból:</h1>
|
||||
<pre id="eredmeny"></pre>
|
||||
<script src="Feladat2.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
92
24_11_11_doga/Feladat2.js
Normal file
92
24_11_11_doga/Feladat2.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
let url = "https://jsonplaceholder.typicode.com/posts/1/comments";
|
||||
let eredmeny = document.getElementById("eredmeny");
|
||||
|
||||
async function adatlekeres(url) {
|
||||
try{
|
||||
let response = await fetch(url);
|
||||
if(!response.ok){
|
||||
throw new Error("HIBA, a response nem OK");
|
||||
} else{
|
||||
let data = await response.json();
|
||||
return data;
|
||||
}
|
||||
} catch{
|
||||
console.log("Hiba történt!");
|
||||
}
|
||||
}
|
||||
|
||||
function createDomElement(element) {
|
||||
let line = document.createElement("div");
|
||||
line.innerHTML = `ID: ${element.id}, Email: ${element.email}`;
|
||||
eredmeny.appendChild(line);
|
||||
}
|
||||
|
||||
async function selectSpecifiedData(dataset){
|
||||
dataset.forEach(element => {
|
||||
if (element.id == 1 || element.id == 3 || element.id == 5){
|
||||
createDomElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createDomElementFullDescription(element){
|
||||
let line = document.createElement("pre");
|
||||
line.innerHTML = element.commentInfok();
|
||||
eredmeny.appendChild(line);
|
||||
}
|
||||
|
||||
|
||||
class Comment{
|
||||
constructor(id, nev, email, tartalom){
|
||||
this.id = id;
|
||||
this.nev = nev;
|
||||
this.email = email;
|
||||
this.tartalom = tartalom;
|
||||
}
|
||||
|
||||
commentInfok(){
|
||||
return `A komment azonosítója: ${this.id}, neve: ${this.nev}, hozzátársuló email cím: ${this.email}, komment tartalma: ${this.tartalom}\n`;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class CommentGyujtemeny{
|
||||
commentek = [];
|
||||
|
||||
constructor(commentek){
|
||||
this.commentek = commentek;
|
||||
}
|
||||
|
||||
commentBegyujtes(comment){
|
||||
this.commentek.push(comment);
|
||||
}
|
||||
|
||||
megjelenites() {
|
||||
this.commentek.forEach(element => {
|
||||
createDomElementFullDescription(element);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function returnAllCommentsAsObject(dataset){
|
||||
let commentek = [];
|
||||
dataset.forEach(element => {
|
||||
if (element.id == 1 || element.id == 3 || element.id == 5){
|
||||
commentek.push(new Comment(element.id, element.name, element.email, element.body));
|
||||
}
|
||||
})
|
||||
return commentek;
|
||||
}
|
||||
|
||||
|
||||
async function main(){
|
||||
let adatok = await adatlekeres(url);
|
||||
//await selectSpecifiedData(adatok);
|
||||
let commentek = returnAllCommentsAsObject(adatok);
|
||||
let commentGyujtemeny = new CommentGyujtemeny(commentek);
|
||||
commentGyujtemeny.megjelenites();
|
||||
}
|
||||
|
||||
|
||||
main();
|
69
24_11_11_doga/Feladat3.js
Normal file
69
24_11_11_doga/Feladat3.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
class Uvegautomata{
|
||||
static uvegDarabszam = 0;
|
||||
|
||||
constructor(maxKapacitas){
|
||||
this.maxKapacitas = maxKapacitas;
|
||||
}
|
||||
|
||||
uvegek = {
|
||||
szines: 0,
|
||||
atlatszo : 0
|
||||
}
|
||||
|
||||
uvegBehelyez(tipus){
|
||||
let currentCapacity = this.uvegek.szines + this.uvegek.atlatszo;
|
||||
if(currentCapacity < this.maxKapacitas){
|
||||
if(tipus == "színes"){
|
||||
this.uvegek.szines++;
|
||||
Uvegautomata.uvegDarabszam++;
|
||||
} else if(tipus == "átlátszó"){
|
||||
this.uvegek.atlatszo++;
|
||||
Uvegautomata.uvegDarabszam++;
|
||||
} else{
|
||||
console.log("Az üveg nem a megfelelő típusú!");
|
||||
}
|
||||
} else{
|
||||
console.log("Az automata tele van!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
kapacitasEllenorzes(){
|
||||
let currentCapacity = this.uvegek.szines + this.uvegek.atlatszo;
|
||||
return `Bedobott üvegek: ${currentCapacity}, Ennyi hely van még az automatában: ${this.maxKapacitas - currentCapacity}`;
|
||||
}
|
||||
|
||||
kiurit(){
|
||||
this.uvegek.atlatszo = 0;
|
||||
this.uvegek.szines = 0;
|
||||
|
||||
return "Autómata kiürítve!";
|
||||
}
|
||||
}
|
||||
|
||||
let automata = new Uvegautomata(10);
|
||||
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
|
||||
//típus ellenőrzés tesztelés
|
||||
automata.uvegBehelyez("fekete");
|
||||
|
||||
|
||||
//Max limit tesztelés
|
||||
/*
|
||||
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
automata.uvegBehelyez("színes");
|
||||
automata.uvegBehelyez("átlátszó");
|
||||
*/
|
||||
console.log(automata.kapacitasEllenorzes());
|
||||
console.log(automata.kiurit());
|
||||
console.log(automata.kapacitasEllenorzes());
|
BIN
24_11_11_doga/Frontend Programozás Dolgozat - November.pdf
Normal file
BIN
24_11_11_doga/Frontend Programozás Dolgozat - November.pdf
Normal file
Binary file not shown.
BIN
24_11_11_doga/szabomarton_24_11_11_doga.zip
Normal file
BIN
24_11_11_doga/szabomarton_24_11_11_doga.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user