Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
6fa68b07b8 | |||
5fe83d7ee8 | |||
19dcae87c3 | |||
a52e81d6c8 | |||
897ef9bf4b | |||
6784d02b95 | |||
befd8c1e8b | |||
9429a39b3c | |||
6ba738d773 |
5 changed files with 14 additions and 112 deletions
16
README.md
16
README.md
|
@ -1,5 +1,17 @@
|
|||
# PPJ
|
||||
|
||||
This branch contains the solution for the **7th task**.
|
||||
This repository exists to archive PJATK tasks for the PPJ curriculum.
|
||||
|
||||
[Go back to main](/femsci/ppj/src/branch/nya)
|
||||
Each task can be found under its **corresponding branch**: `task/n`.
|
||||
|
||||
### Completed tasks:
|
||||
|
||||
- [Task 1](/femsci/ppj/src/branch/task/1)
|
||||
- [Task 2](/femsci/ppj/src/branch/task/2)
|
||||
- [Task 3](/femsci/ppj/src/branch/task/3)
|
||||
- [Task 4](/femsci/ppj/src/branch/task/4)
|
||||
- [Task 5](/femsci/ppj/src/branch/task/5)
|
||||
- [Task 6](/femsci/ppj/src/branch/task/6)
|
||||
- [Task 7](/femsci/ppj/src/branch/task/7)
|
||||
- [Task 8](/femsci/ppj/src/branch/task/8)
|
||||
- [Task 9](/femsci/ppj/src/branch/task/9)
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* TASK 7
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/7
|
||||
* by femsci
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
public class Book {
|
||||
public Book(String author, String title, String body) {
|
||||
this.author = author;
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
private final String author, title, body;
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* TASK 7
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/7
|
||||
* by femsci
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Library {
|
||||
public Library(Shelf[] shelves) {
|
||||
this.shelves = shelves;
|
||||
}
|
||||
|
||||
private final Shelf[] shelves;
|
||||
|
||||
public Shelf[] getShelves() {
|
||||
return shelves;
|
||||
}
|
||||
|
||||
public int countAuthor(String author) {
|
||||
return (int) Arrays.asList(shelves).stream().flatMap(x -> Arrays.stream(x.getBooks()))
|
||||
.filter(f -> f.getAuthor().equals(author)).count();
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* TASK 7
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/7
|
||||
* by femsci
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
public class Nyaaaaaa {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Shelf sh1 = new Shelf("Shelf1",
|
||||
new Book[] {
|
||||
new Book("Babel", "Odessa Tales", "babelode"),
|
||||
new Book("Joyce", "Ulisses", "joyceuli")
|
||||
});
|
||||
|
||||
Shelf sh2 = new Shelf("Shelf2",
|
||||
new Book[] {
|
||||
new Book("Mann", "Dr Faustus", "mannfau"),
|
||||
new Book("Babel", "Red Cavalry", "babelred")
|
||||
});
|
||||
|
||||
Library lib = new Library(new Shelf[] { sh1, sh2 });
|
||||
|
||||
System.out.printf("# of books by this author: %d\n",
|
||||
lib.countAuthor("Babel"));
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* TASK 7
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/7
|
||||
* by femsci
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
//final class :3c
|
||||
public class Shelf {
|
||||
public Shelf(String id, Book[] books) {
|
||||
this.id = id;
|
||||
this.books = books;
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final Book[] books;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Book[] getBooks() {
|
||||
return books;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue