Skip to content

Commit a5f010e

Browse files
committed
change gitignore, add materials from Software technologies course
1 parent bd76c08 commit a5f010e

File tree

72 files changed

+1571
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1571
-2
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
33

44
# User-specific stuff:
5-
.idea/*
6-
*.iml
5+
*/.idea
6+
.idea/**/workspace.xml
7+
.idea/**/tasks.xml
8+
79

810
# Sensitive or high-churn files:
911
.idea/**/dataSources/

JavaBasics/JavaBasics.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Random;
2+
import java.util.Scanner;
3+
4+
public class AdvertisementMessage {
5+
public static void main(String[] args) {
6+
Scanner console = new Scanner(System.in);
7+
8+
int messagesCount = Integer.parseInt(console.nextLine());
9+
10+
String[] phrases = {"Excellent product.", "Such a great product.", "I always use that product.", "Best product of its category.", "Exceptional product.", "I can’t live without this product."};
11+
String[] events = {"Now I feel good.", "I have succeeded with this product.", "Makes miracles.I am happy of the results!", "I cannot believe but now I feel awesome.", "Try it yourself, I am very satisfied.", "I feel great!"};
12+
String[] authors = {"Diana", "Petya", "Stella", "Elena", "Katya", "Iva", "Annie", "Eva"};
13+
String[] cities = {"Burgas", "Sofia", "Plovdiv", "Varna", "Ruse"};
14+
15+
Random rand = new Random();
16+
17+
for (int i = 0; i < messagesCount; i++) {
18+
19+
String randomPhrase = phrases[rand.nextInt(phrases.length)];
20+
String randomEvent = events[rand.nextInt(phrases.length)];
21+
String randomAuthor = authors[rand.nextInt(phrases.length)];
22+
String randomCity = cities[rand.nextInt(phrases.length)];
23+
24+
System.out.printf("%s %s %s - %s%n", randomPhrase, randomEvent, randomAuthor, randomCity);
25+
}
26+
}
27+
28+
29+
}

JavaBasics/src/AverageGrades.java

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import java.util.*;
2+
import java.util.stream.Collectors;
3+
4+
public class AverageGrades {
5+
public static void main(String[] args) {
6+
Scanner console = new Scanner(System.in);
7+
8+
String[] totalStudentsStr = console.nextLine().split(" ");
9+
int totalStudents = Integer.parseInt(totalStudentsStr[0]);
10+
ArrayList<Student> students = new ArrayList<Student>();
11+
12+
for (int i = 0; i < totalStudents; i++) {
13+
14+
String[] input = console.nextLine().split(" ");
15+
String name = input[0];
16+
Student currentStudent = new Student();
17+
currentStudent.name = name;
18+
ArrayList<Double> gradesList = new ArrayList<Double>();
19+
20+
for (int j = 1; j < input.length; j++) {
21+
gradesList.add(Double.parseDouble(input[j]));
22+
}
23+
double sum = 0;
24+
for (int k = 0; k < gradesList.size(); k++) {
25+
sum += gradesList.get(k);
26+
}
27+
double avg = sum / gradesList.size();
28+
currentStudent.setGrades(gradesList);
29+
currentStudent.setAvgGrade(avg);
30+
students.add(currentStudent);
31+
}
32+
33+
List<Student> result = students.stream()
34+
.filter(a -> a.avgGrade >= 5.00)
35+
.sorted(Comparator.comparing(Student::getName)
36+
.thenComparing(Student::getAvgGrade, Comparator.reverseOrder()))
37+
.collect(Collectors.toList());
38+
39+
String newLine = System.getProperty("line.separator");
40+
for (int i = 0; i < result.size(); i++) {
41+
System.out.printf("%s -> %.2f%s", result.get(i).name, result.get(i).avgGrade, newLine);
42+
}
43+
}
44+
45+
public static class Student {
46+
public String getName() {
47+
return name;
48+
}
49+
50+
public void setName(String name) {
51+
this.name = name;
52+
}
53+
54+
public ArrayList<Double> getGrades() {
55+
return Grades;
56+
}
57+
58+
public void setGrades(ArrayList<Double> grades) {
59+
Grades = grades;
60+
}
61+
62+
public String name;
63+
public ArrayList<Double> Grades;
64+
65+
66+
public double getAvgGrade() {
67+
return avgGrade;
68+
}
69+
70+
public void setAvgGrade(double avgGrade) {
71+
this.avgGrade = avgGrade;
72+
}
73+
74+
public double avgGrade;
75+
}
76+
}

JavaBasics/src/BookLibrary.java

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import java.time.LocalDate;
2+
import java.time.format.DateTimeFormatter;
3+
import java.util.*;
4+
5+
public class BookLibrary {
6+
public static void main(String[] args) {
7+
Scanner console = new Scanner(System.in);
8+
9+
DateTimeFormatter f = DateTimeFormatter.ofPattern("dd.MM.yyyy");
10+
String[] quantityBooksStr = console.nextLine().split(" ");
11+
int quantityBooks = Integer.parseInt(quantityBooksStr[0]);
12+
Library privateLib = new Library();
13+
privateLib.setBooks(new ArrayList<Book>());
14+
ArrayList<Book> listBooks = new ArrayList<>();
15+
16+
for (int i = 0; i < quantityBooks; i++) {
17+
String[] bookArgs = console.nextLine().split(" ");
18+
Book currentBook = new Book();
19+
currentBook.setTitle(bookArgs[0]);
20+
currentBook.setAuthor(bookArgs[1]);
21+
currentBook.setPublisher(bookArgs[2]);
22+
LocalDate date = LocalDate.from(f.parse(bookArgs[3]));
23+
currentBook.setReleaseDate(date);
24+
currentBook.setISBN(bookArgs[4]);
25+
currentBook.setPrice(Double.parseDouble(bookArgs[5]));
26+
27+
listBooks.add(currentBook);
28+
}
29+
privateLib.setBooks(listBooks);
30+
31+
HashMap<String, Double> authorsWithBooks = new HashMap<>();
32+
33+
for (Book book : privateLib.getBooks()) {
34+
if (!authorsWithBooks.containsKey(book.getAuthor())) {
35+
authorsWithBooks.put(book.getAuthor(), book.getPrice());
36+
} else {
37+
authorsWithBooks.put(book.getAuthor(), authorsWithBooks.get(book.getAuthor()) + book.getPrice());
38+
}
39+
}
40+
41+
String newLine = System.getProperty("line.separator");
42+
authorsWithBooks.entrySet().stream()
43+
.sorted(Map.Entry.<String, Double>comparingByValue()
44+
.reversed()
45+
.thenComparing(Map.Entry.comparingByKey()))
46+
.forEach(x -> System.out.printf("%s -> %.2f%s", x.getKey(), x.getValue(), newLine));
47+
48+
}
49+
50+
public static class Book {
51+
public String getTitle() {
52+
return Title;
53+
}
54+
55+
private void setTitle(String title) {
56+
Title = title;
57+
}
58+
59+
private String getAuthor() {
60+
return Author;
61+
}
62+
63+
private void setAuthor(String author) {
64+
Author = author;
65+
}
66+
67+
public String getPublisher() {
68+
return Publisher;
69+
}
70+
71+
private void setPublisher(String publisher) {
72+
Publisher = publisher;
73+
}
74+
75+
public LocalDate getReleaseDate() {
76+
return ReleaseDate;
77+
}
78+
79+
private void setReleaseDate(LocalDate releaseDate) {
80+
ReleaseDate = releaseDate;
81+
}
82+
83+
public String getISBN() {
84+
return ISBN;
85+
}
86+
87+
private void setISBN(String ISBN) {
88+
this.ISBN = ISBN;
89+
}
90+
91+
private double getPrice() {
92+
return Price;
93+
}
94+
95+
private void setPrice(double price) {
96+
Price = price;
97+
}
98+
99+
private String Title;
100+
private String Author;
101+
private String Publisher;
102+
private LocalDate ReleaseDate;
103+
private String ISBN;
104+
private double Price;
105+
}
106+
107+
public static class Library {
108+
public String getName() {
109+
return Name;
110+
}
111+
112+
public void setName(String name) {
113+
Name = name;
114+
}
115+
116+
private ArrayList<Book> getBooks() {
117+
return Books;
118+
}
119+
120+
private void setBooks(ArrayList<Book> books) {
121+
Books = books;
122+
}
123+
124+
private String Name;
125+
private ArrayList<Book> Books;
126+
}
127+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import java.time.LocalDate;
2+
import java.time.format.DateTimeFormatter;
3+
import java.util.*;
4+
import java.util.stream.Collectors;
5+
6+
public class BookLibraryModification {
7+
public static void main(String[] args) {
8+
Scanner console = new Scanner(System.in);
9+
10+
DateTimeFormatter f = DateTimeFormatter.ofPattern("dd.MM.yyyy");
11+
String[] quantityBooksStr = console.nextLine().split(" ");
12+
int quantityBooks = Integer.parseInt(quantityBooksStr[0]);
13+
Library privateLib = new Library();
14+
privateLib.setBooks(new ArrayList<Book>());
15+
ArrayList<Book> listBooks = new ArrayList<>();
16+
17+
for (int i = 0; i < quantityBooks; i++) {
18+
String[] bookArgs = console.nextLine().split(" ");
19+
Book currentBook = new Book();
20+
currentBook.setTitle(bookArgs[0]);
21+
currentBook.setAuthor(bookArgs[1]);
22+
currentBook.setPublisher(bookArgs[2]);
23+
LocalDate date = LocalDate.from(f.parse(bookArgs[3]));
24+
currentBook.setReleaseDate(date);
25+
currentBook.setISBN(bookArgs[4]);
26+
currentBook.setPrice(Double.parseDouble(bookArgs[5]));
27+
28+
listBooks.add(currentBook);
29+
}
30+
privateLib.setBooks(listBooks);
31+
32+
String newLine = System.getProperty("line.separator");
33+
String afterDateStr = console.nextLine();
34+
LocalDate afterDate = LocalDate.from(f.parse(afterDateStr));
35+
36+
List<Book> result = privateLib.getBooks().stream()
37+
.filter(b -> b.getReleaseDate().isAfter(afterDate))
38+
.sorted(Comparator.comparing(Book::getReleaseDate)
39+
.thenComparing(Book::getTitle))
40+
.collect(Collectors.toList());
41+
42+
43+
for (int i = 0; i < result.size(); i++) {
44+
System.out.printf("%s -> %s%s", result.get(i).getTitle(), result.get(i).getReleaseDate().format(f), newLine);
45+
}
46+
}
47+
48+
public static class Book {
49+
public String getTitle() {
50+
return Title;
51+
}
52+
53+
private void setTitle(String title) {
54+
Title = title;
55+
}
56+
57+
private String getAuthor() {
58+
return Author;
59+
}
60+
61+
private void setAuthor(String author) {
62+
Author = author;
63+
}
64+
65+
public String getPublisher() {
66+
return Publisher;
67+
}
68+
69+
private void setPublisher(String publisher) {
70+
Publisher = publisher;
71+
}
72+
73+
public LocalDate getReleaseDate() {
74+
return ReleaseDate;
75+
}
76+
77+
private void setReleaseDate(LocalDate releaseDate) {
78+
ReleaseDate = releaseDate;
79+
}
80+
81+
public String getISBN() {
82+
return ISBN;
83+
}
84+
85+
private void setISBN(String ISBN) {
86+
this.ISBN = ISBN;
87+
}
88+
89+
private double getPrice() {
90+
return Price;
91+
}
92+
93+
private void setPrice(double price) {
94+
Price = price;
95+
}
96+
97+
private String Title;
98+
private String Author;
99+
private String Publisher;
100+
private LocalDate ReleaseDate;
101+
private String ISBN;
102+
private double Price;
103+
}
104+
105+
public static class Library {
106+
public String getName() {
107+
return Name;
108+
}
109+
110+
public void setName(String name) {
111+
Name = name;
112+
}
113+
114+
private ArrayList<Book> getBooks() {
115+
return Books;
116+
}
117+
118+
private void setBooks(ArrayList<Book> books) {
119+
Books = books;
120+
}
121+
122+
private String Name;
123+
private ArrayList<Book> Books;
124+
}
125+
}

0 commit comments

Comments
 (0)