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

Kenan Turgay #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# Java Sets

### Proje Kurulumu

Projeyi öncelikle forklayın ve clone edin.
Daha sonra projeyi IntellijIDEA kullanarak açınız. README.md dosyasını dikkatli bir şekilde okuyarak istenenleri yapmaya çalışın.
Proje sayımız ilerledikçe proje yönetimimizi kolaylaştırmak adına projelerimizi belli klasör kalıplarında saklamak işimizi kolaylaştırmak adına iyi bir alışkanlıktır.
Örnek bir Lokasyon: Workintech/Sprint_1/Etud.
# Hedeflerimiz:

### Hedeflerimiz:

### 1-)Set Challenge
## 1-)Set Challenge

* org.example.entity paketi altında İki tane sınıfımız olucak. ```Task``` ve ```TaskData```
* ```Task``` sınıfı içerisinde 5 tane ```instance variable``` olmalı. ```project``` => string ```description``` => string ```assignee``` => string
Expand All @@ -19,7 +12,7 @@ Proje sayımız ilerledikçe proje yönetimimizi kolaylaştırmak adına projele
* TaskData sınıfı 4 tane değişkene sahip olmalı ```annsTasks => Set<Task>``` ```bobsTasks => Set<Task>``` ```carolsTasks => Set<Task>``` ```unassignedTasks => Set<Task>``` Bu 4 değerde constructor vasıtasıyla set edilebilmeli.
* TaskData sınıfı ```getTasks()``` adlı bir metoda sahip olmalı. method parametre olarak bir String almalı. Bu 4 değerden herhangi birini alabilir. ("ann", "bob", "carol", "all") Metodun dönüş değeri ```Set<Task>``` olmalı.

### Senaryo
## Senaryo

* Şöyle bir senaryomuz var. Sen şirketteki yeni bir yöneticisin ve ekibinde 3 tane çalışanın var.
* Ann, Bob, Carol 3'ü de senin çalışanların.
Expand All @@ -38,7 +31,7 @@ Proje sayımız ilerledikçe proje yönetimimizi kolaylaştırmak adına projele
* ```getIntersect()``` metodu iki tane set alır ve aralarındaki kesişim kümesini bulup döner.
* ```getDifference()``` metodu iki tane set alır ve ikinci set içerisindeki verileri ilk set içerisindeki verilerden çıkarır.

### 2-) Challenge
## 2-) Challenge

* Elimizde aşağıdaki gibi bir text mevcut.
* org.example.entity paketi altında StringSet adında bir sınıf tanımlayın.
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package org.example;

import org.example.entity.StringSet;

import java.util.Set;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");

Set<String> uniqueWords = StringSet.findUniqueWords();
System.out.println("Benzersiz kelimeler: " + uniqueWords);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/example/entity/Priority.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.example.entity;

public enum Priority {
HIGH, MED, LOW
}
5 changes: 5 additions & 0 deletions src/main/java/org/example/entity/Status.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.example.entity;

public enum Status {
IN_QUEUE, ASSIGNED, IN_PROGRESS
}
42 changes: 42 additions & 0 deletions src/main/java/org/example/entity/StringSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.example.entity;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

public class StringSet {

public static Set<String> findUniqueWords() {
String text = "Carroll began writing the manuscript of the story the next day, although that earliest version is lost. "
+ "The girls and Carroll took another boat trip a month later, when he elaborated the plot to the story of Alice, "
+ "and in November he began working on the manuscript in earnest. To add the finishing touches he researched "
+ "natural history in connection with the animals presented in the book and then had the book examined "
+ "by other children—particularly those of George MacDonald. Though Carroll did add his own illustrations "
+ "to the original copy, on publication he was advised to find a professional illustrator so the pictures "
+ "were more appealing to its audiences. He subsequently approached John Tenniel to reinterpret "
+ "Carroll's visions through his own artistic eye, telling him that the story had been well liked by the "
+ "children.\n"
+ "\n"
+ "Carroll began planning a print edition of the Alice story in 1863. "
+ "He wrote on 9 May 1863 that MacDonald's family had suggested he publish Alice. "
+ "A diary entry for 2 July says that he received a specimen page of the print edition around that date. "
+ "On 26 November 1864, Carroll gave Alice the manuscript of Alice's Adventures Under Ground, with illustrations "
+ "by Carroll, dedicating it as \"A Christmas Gift to a Dear Child in Memory of a Summer's Day\". "
+ "The published version of Alice's Adventures in Wonderland is about twice the length of "
+ "Alice's Adventures Under Ground and includes episodes, such as the Mad Tea-Party, "
+ "that did not appear in the manuscript. The only known manuscript copy of Under Ground "
+ "is held in the British Library. Macmillan published a facsimile of the manuscript in 1886.";

// Özel karakterleri temizle
String cleanedText = text.replaceAll("[.,!?\"'—]", "").toLowerCase();

// Kelimeleri ayır ve benzersiz olanları bul
Set<String> uniqueWords = new HashSet<>(Arrays.asList(cleanedText.split("\\s+")));

// Benzersiz kelimeleri alfabetik sıraya koy ve döndür
return uniqueWords;
}

}
73 changes: 73 additions & 0 deletions src/main/java/org/example/entity/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.example.entity;

import java.util.Objects;

public class Task {
private String project;
private String description;
private String assignee;
private Status status;
private Priority priority;


public Task(String project, String description, String assignee, Status status, Priority priority) {
this.project = project;
this.description = description;
this.assignee = assignee;
this.status = status;
this.priority = priority;
}

public String getProject() {
return project;
}

public String getDescription() {
return description;
}

public String getAssignee() {
return assignee;
}

public Status getStatus() {
return status;
}

public Priority getPriority() {
return priority;
}

public void setProject(String project) {
this.project = project;
}

public void setDescription(String description) {
this.description = description;
}

public void setAssignee(String assignee) {
this.assignee = assignee;
}

public void setStatus(Status status) {
this.status = status;
}

public void setPriority(Priority priority) {
this.priority = priority;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Task task = (Task) o;
return Objects.equals(project, task.project) && Objects.equals(description, task.description);
}

@Override
public int hashCode() {
return Objects.hash(project, description);
}
}
55 changes: 55 additions & 0 deletions src/main/java/org/example/entity/TaskData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.example.entity;

import org.example.entity.Task;

import java.util.HashSet;
import java.util.Set;

public class TaskData {
private Set<Task> annTasks;
private Set<Task> bobsTasks;
private Set<Task> carolsTasks;
private Set<Task> unassignedTasks;

public TaskData(Set<Task> annTasks, Set<Task> bobsTasks, Set<Task> carolsTasks, Set<Task> unassignedTasks) {
this.annTasks = annTasks;
this.bobsTasks = bobsTasks;
this.carolsTasks = carolsTasks;
this.unassignedTasks = unassignedTasks;
}

public Set<Task> getTasks(String user) {
switch (user.toLowerCase()) {
case "ann":
return annTasks;
case "bob":
return bobsTasks;
case "carol":
return carolsTasks;
case "all":
return getUnion(annTasks, bobsTasks, carolsTasks, unassignedTasks);
default:
return new HashSet<>(); // veya null dönebilirsiniz
}
}

public Set<Task> getUnion(Set<Task>... sets) {
Set<Task> unionSet = new HashSet<>();
for (Set<Task> set : sets) {
unionSet.addAll(set);
}
return unionSet;
}

public Set<Task> getIntersection(Set<Task> set1, Set<Task> set2) {
Set<Task> intersectionSet = new HashSet<>(set1);
intersectionSet.retainAll(set2);
return intersectionSet;
}

public Set<Task> getDifferences(Set<Task> set1, Set<Task> set2) {
Set<Task> differenceSet = new HashSet<>(set1);
differenceSet.removeAll(set2);
return differenceSet;
}
}
1 change: 1 addition & 0 deletions src/test/java/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/ResultAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void afterAll(ExtensionContext context) throws Exception {
long failure = summary.get(TestResultStatus.FAILED) != null ? summary.get(TestResultStatus.FAILED) : 0;

double score = (double) success / (success + failure);
String userId = "999999";
String userId = "179820";

JSONObject json = new JSONObject();
json.put("score", score);
Expand Down
Binary file added target/classes/org/example/Main.class
Binary file not shown.
Binary file added target/classes/org/example/entity/Priority.class
Binary file not shown.
Binary file added target/classes/org/example/entity/Status.class
Binary file not shown.
Binary file added target/classes/org/example/entity/StringSet.class
Binary file not shown.
Binary file added target/classes/org/example/entity/Task.class
Binary file not shown.
Binary file added target/classes/org/example/entity/TaskData.class
Binary file not shown.
Binary file added target/test-classes/MainTest.class
Binary file not shown.
Binary file not shown.
Binary file added target/test-classes/ResultAnalyzer.class
Binary file not shown.