Skip to content
Snippets Groups Projects
Commit c6502e34 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

solution

parent 5681fdf8
No related merge requests found
package koz01.java2.lab06;
import java.util.ResourceBundle;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
......@@ -14,9 +17,10 @@ public class App extends Application {
@Override
public void start(Stage primaryStage) {
try {
Scene scene = new Scene(FXMLLoader.load(getClass().getResource(
"screen.fxml")), 400, 400);
ResourceBundle rb = ResourceBundle.getBundle("koz01.java2.lab06.Texts");
Parent parent = FXMLLoader.load(getClass().getResource("screen.fxml"),
rb);
Scene scene = new Scene(parent, 400, 400);
scene.getStylesheets().add(getClass().getResource("application.css")
.toExternalForm());
primaryStage.setScene(scene);
......
color=Barva
greeting=Ahoj
title=pane
label=Label
\ No newline at end of file
color=Barva
greeting=\u010Cau
title=kmo
label=Popisek
\ No newline at end of file
greeting=Hello
\ No newline at end of file
color=colour
\ No newline at end of file
color=color
......@@ -7,7 +7,7 @@
<AnchorPane prefHeight="484.0" prefWidth="550.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label layoutX="129.0" layoutY="41.0" prefHeight="31.0" prefWidth="292.0" text="Label" />
<Label layoutX="129.0" layoutY="41.0" prefHeight="31.0" prefWidth="292.0" text="%label" />
<Button layoutX="197.0" layoutY="300.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="156.0" text="Button" />
</children>
</AnchorPane>
package koz01.java2.lab06;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;
import java.util.ResourceBundle;
import org.junit.jupiter.api.Test;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class DemoLocale {
@Test
public void testLocaleCreation() {
Locale locale = Locale.getDefault();
log.info("locale = {}", locale);
}
@Test
public void testResourceBundle() {
ResourceBundle resourceBundle = ResourceBundle.getBundle(
"koz01.java2.lab06.Texts", new Locale("ro", "RO"));
log.info("color = {}", resourceBundle.getObject("color"));
log.info("greeting = {} {}", resourceBundle.getObject("greeting"),
resourceBundle.getObject("title"));
}
@Test
public void testFormatNumber() {
log.info(String.format(Locale.KOREA, "%f\n", Math.PI));
}
@Test
public void testFormatDate() {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDate(
FormatStyle.FULL).localizedBy(Locale.CHINA);
log.info("actual date = " + dateTimeFormatter.format(LocalDate.now()));
}
}
package koz01.java2.lab06;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.junit.jupiter.api.Test;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class DemoNumbers {
@Test
public void testDouble() {
double val = 0.1;
for (int i = 0; i < 10; i++) {
val += 0.1;
}
log.info("result = {}", val);
}
@Test
public void testBigDecimal() {
BigDecimal val = BigDecimal.valueOf(1, 1);
BigDecimal result = val;
for (int i = 0; i < 10; i++) {
result = result.add(val);
}
log.info("result = {}", val);
}
@Test
public void testEquals() {
BigDecimal val1 = BigDecimal.valueOf(1, 1);
BigDecimal val2 = BigDecimal.valueOf(10, 2);
log.info("val1 = {}, val2 = {}", val1, val2);
log.info("val1.equals(val2) = {}", val1.equals(val2));
}
@Test
public void testFactorial() {
BigInteger val = BigInteger.ONE;
final int fact = 20000;
for (int i = 2; i <= fact; i++) {
val = val.multiply(BigInteger.valueOf(i));
}
log.info("fact({})={}", fact, val);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment