-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="WEB_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Practica Guiada</title> | ||
</head> | ||
<body> | ||
<script src="pratica.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "clases_y_objetos_Practica", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
class Book{ | ||
constructor(title, author, year, gender){ | ||
this.title = title | ||
this.author = author | ||
this.year = year | ||
this.gender = gender | ||
} | ||
getAuthor (){ | ||
return this.author | ||
} | ||
getGender(){ | ||
return this.gender | ||
} | ||
bookInfo(){ | ||
return `${this.title} es un libro de ${this.gender} escrito por ${this.author} en el año ${this.year}` | ||
} | ||
} | ||
let books = [] | ||
while (books.length<1){ | ||
let title = prompt('Intruduce el titulo del libro') | ||
let author = prompt('Intruduce el autor del libro') | ||
let year = prompt('Intruduce el año del libro') | ||
let gender = prompt('Intruduce el genero del libro').toLowerCase() | ||
|
||
if(title !='' && author !='' && !isNaN(year) && year.length == 4 && (gender == 'aventura' || gender == 'terror' || gender =='fantasia')){ | ||
books.push(new Book(title, author, year, gender)) | ||
} | ||
} | ||
|
||
const showAllBooks = () => { | ||
console.log(books); | ||
} | ||
const showAuthors = () => { | ||
let authors = [] | ||
|
||
for (const book of books ){ | ||
authors.push(book.getAuthor()); | ||
} | ||
console.log(authors.sort()); | ||
} | ||
|
||
const showGender = () =>{ | ||
const gender = prompt('Introduce el genero a buscar') | ||
for (const book of books ){ | ||
if(book.getGender() == gender){ | ||
console.log(book.bookInfo()) | ||
} | ||
} | ||
} | ||
|
||
//showAuthors() | ||
showGender() |