Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalWds committed Mar 24, 2019
1 parent 063304e commit 695587f
Show file tree
Hide file tree
Showing 15 changed files with 286 additions and 283 deletions.
12 changes: 3 additions & 9 deletions src/main/java/dictionary_game/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Library {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id; // zeby nadawac id w mysql
private Integer id;

@NotNull
private String englishWord;
Expand Down Expand Up @@ -64,13 +64,7 @@ public void setPolishWord(String polishWord) {
@Override
public String toString() {
return englishWord + polishWord;
// to co nam zwraca z library w wywolaniu
}// lepiej wrzucic kolejnego to stringa do innej klasy zeby byla czystosc, klodu ( w momencie gdy robimy polishword

// public String getMessage() {
//
// if (polishWord.equalsIgnoreCase(dictionaryController.getPWord()));
// return "ass";
//}

}

}
10 changes: 3 additions & 7 deletions src/main/java/dictionary_game/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public String create(@Valid User user, BindingResult bindingResult) {


@GetMapping("/")
public String Start(ModelMap modelMap){
public String Start(ModelMap modelMap) {

modelMap.put("start",user.getNumberOfPoints());
modelMap.put("start", user.getNumberOfPoints());
user.setNumberOfPoints(0);

return "home";
}


@GetMapping("/score")
public String showPoints(ModelMap modelMap){
public String showPoints(ModelMap modelMap) {

User userData = userRepository.findByName(GameScore.username);
userData.setNumberOfPoints(user.getNumberOfPoints());
Expand All @@ -73,8 +73,4 @@ Iterable<User> getAllUsers() {
}






}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public String findAll(ModelMap modelMap) {
}



@GetMapping("/add")
public String show(ModelMap modelMap) {
modelMap.put("user", new User());
Expand All @@ -46,7 +45,4 @@ public String show(ModelMap modelMap) {
}





}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dictionary_game.repositories;


import dictionary_game.Library;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import dictionary_game.Library;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
import java.util.List;

public interface LibraryRepository extends CrudRepository<Library, Integer> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import java.util.List;

public interface UserRepository extends CrudRepository<User,Integer> {
public interface UserRepository extends CrudRepository<User, Integer> {

@Query("SELECT p FROM User p ORDER BY p.id")
List<User> findAllSortById();

@Query("select p from User p where p.name = ?1")
User findByName(String name);

//search by name

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class DictionaryRoundThreeService {

private Random random = new Random();
private int round =0;
private int round = 0;
private int count;
private int index;
private String EWord;
Expand Down Expand Up @@ -51,34 +51,30 @@ public String getPolishW() {
}


public String getHashEnglish(){
public String getHashEnglish() {

String HashWord=EWord;
String HashWord = EWord;
for (int i = 0; i < round; i += 2) {
char randomChar = HashWord.charAt(random.nextInt(HashWord.length()-1));
HashWord = HashWord.replaceFirst(String.valueOf(randomChar), "#" );
if(randomChar=='#' || randomChar==0) continue;
char randomChar = HashWord.charAt(random.nextInt(HashWord.length() - 1));
HashWord = HashWord.replaceFirst(String.valueOf(randomChar), "#");
if (randomChar == '#' || randomChar == 0) continue;

}
return HashWord;

return HashWord;

}


public String getMessage(String name3) {



while (name3 != null) {

if (!name3.equals(EWord) || name3 == "") {
user.substractPoints();
user.substractPoints();
round--;

return "Niestety źle! -1pkt! ";
} else {
user.addPoint();
user.addPoint();

round++;
return "Tak trzymać! +1pkt! ";
Expand Down
44 changes: 24 additions & 20 deletions src/main/resources/templates/form.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head th:replace="/players :: head"></head>
<meta charset="UTF-8">
<title>WriteYourName</title>
<meta charset="UTF-8">
<title>WriteYourName</title>
<style>
h1 {color: crimson}
h1 {
color: crimson
}
</style>
</head>
<body>
<div class="background-roundone">
<div style="background-color: rgba(100, 0, 400, 0.3);padding:200px;width: 50%; margin-left:100px; content: '50';">

<form th:action="@{/home}" th:object="${user}" method="post">
<input type="hidden" th:field="*{id}">
<div align="center">
<h1>Podaj imię:</h1>
<br>
<table>
<tr>
<td><input type="text" th:field="*{name}" /></td>
<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>
</tr>
<tr >
<form th:action="@{/home}" th:object="${user}" method="post">
<input type="hidden" th:field="*{id}">
<div align="center">
<h1>Podaj imię:</h1>
<br>
<table>
<tr>
<td><input type="text" th:field="*{name}"/></td>
<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>
</tr>
<tr>

<td><button class="btn btn-primary btn-lg" type="submit">Graj</button></td>
</tr>
</table>
</br>
</div>
</form>
<td>
<button class="btn btn-primary btn-lg" type="submit">Graj</button>
</td>
</tr>
</table>
</br>
</div>
</form>
</div>

</body>
Expand Down
19 changes: 9 additions & 10 deletions src/main/resources/templates/help.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head th:replace="/players :: head"></head>
<meta charset="UTF-8">
<title>Podpowiedź</title>
<meta charset="UTF-8">
<title>Podpowiedź</title>
</head>
<body>

<div class="background-help">
<div style="background-color: rgba(0, 0, 255, 0.7);padding:20px;width:1000px; margin-left:100px;">

<form action="/r1">
<h1> Tłumaczenie slowa to : </h2>
<h3 tłumaczenie słowa to</h3>
<p th:text="${help}"></p>
<form action="/r1">
<h1> Tłumaczenie slowa to : </h2>
<h3 tłumaczenie słowa to</h3>
<p th:text="${help}"></p>

<input type="text" name="polishW" style="margin-top: 2px;">
<input type="submit" value="wpisz i wróć" class="btn btn-primary btn-lg">
<input type="text" name="polishW" style="margin-top: 2px;">
<input type="submit" value="wpisz i wróć" class="btn btn-primary btn-lg">



</form>
</form>
</body>
</html>
25 changes: 12 additions & 13 deletions src/main/resources/templates/help2.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
<head th:replace="/players :: head"></head>
<div class="background-help2">
<div style="background-color: rgba(0, 0, 255, 0.7);padding:20px;width:1000px; margin-left:100px;">
<meta charset="UTF-8">
<title>Podpowiedź</title>
</head>
<body>
<label><h1>Tłumaczenie slowa to : </h1></label>
<meta charset="UTF-8">
<title>Podpowiedź</title>
</head>
<body>
<label><h1>Tłumaczenie slowa to : </h1></label>


<form action="/r2">
<form action="/r2">

<h3 tłumaczenie słowa to</h3>
<p th:text="${help2}"></p>
<h3 tłumaczenie słowa to</h3>
<p th:text="${help2}"></p>

<input type="text" name="englishW">
<input type="submit" value="wpisz i wróć"class="btn btn-primary btn-lg">
<input type="text" name="englishW">
<input type="submit" value="wpisz i wróć" class="btn btn-primary btn-lg">



</form>
</body>
</form>
</body>
</html>
20 changes: 11 additions & 9 deletions src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
<head th:replace="/players :: head"></head>

<style>
h1 { color: #FF0000; }
h1 {
color: #FF0000;
}
</style>
</head>
<body>
<div class="background-welder">

<div style="text-align: center;vertical-align: center;padding-top:150px;">
<h1> Rozpocznij Grę!</h1>
<div style="text-align: center;vertical-align: center;padding-top:150px;">
<h1> Rozpocznij Grę!</h1>

<form>
<a align="center" th:href="@{/add}">
<button align="center" type="button" class="btn btn-primary btn-lg">START</button>
</a>
</form>
<form>
<a align="center" th:href="@{/add}">
<button align="center" type="button" class="btn btn-primary btn-lg">START</button>
</a>
</form>


</div>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 695587f

Please sign in to comment.