78 lines
4.4 KiB
HTML
78 lines
4.4 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>TicTacToe.java</title>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||
|
.literal {color: #cc7832}
|
||
|
.string {color: #6a8759}
|
||
|
.number {color: #6897bb}
|
||
|
.comment {color: #808080}
|
||
|
.whitespace {color: #505050}
|
||
|
-->
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/MP1_FX_CalebFontenot/src/mp1_fx_calebfontenot/TicTacToe.java</td></tr></table>
|
||
|
<pre>
|
||
|
<span class="comment">/*</span>
|
||
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||
|
<span class="comment"> */</span>
|
||
|
<span class="literal">package</span> mp1_fx_calebfontenot;
|
||
|
|
||
|
|
||
|
<span class="literal">import</span> javafx.application.Application;
|
||
|
<span class="literal">import</span> javafx.geometry.Pos;
|
||
|
<span class="literal">import</span> javafx.scene.Scene;
|
||
|
<span class="literal">import</span> javafx.scene.image.Image;
|
||
|
<span class="literal">import</span> javafx.scene.image.ImageView;
|
||
|
<span class="literal">import</span> javafx.scene.layout.GridPane;
|
||
|
<span class="literal">import</span> javafx.stage.Stage;
|
||
|
|
||
|
<span class="comment">/**</span>
|
||
|
<span class="comment"> *</span>
|
||
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
||
|
<span class="comment">*/</span>
|
||
|
<span class="literal">public</span> <span class="literal">class</span> TicTacToe <span class="literal">extends</span> Application {
|
||
|
|
||
|
@Override
|
||
|
<span class="literal">public</span> <span class="literal">void</span> start(Stage primaryStage) <span class="literal">throws</span> Exception {
|
||
|
<span class="literal">final</span> String BASE_URL = <span class="string">"</span><span class="string">https://files.calebfontenot.com/</span><span class="string">"</span>;
|
||
|
Image imageX = <span class="literal">new</span> Image(BASE_URL + <span class="string">"</span><span class="string">image/x.gif</span><span class="string">"</span>);
|
||
|
Image imageO = <span class="literal">new</span> Image(BASE_URL + <span class="string">"</span><span class="string">image/o.gif</span><span class="string">"</span>);
|
||
|
|
||
|
GridPane pane = <span class="literal">new</span> GridPane();
|
||
|
pane.setAlignment(Pos.CENTER);
|
||
|
pane.setHgap(<span class="number">5</span>);
|
||
|
pane.setVgap(<span class="number">5</span>);
|
||
|
|
||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">3</span>; i++) {
|
||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="number">3</span>; j++) {
|
||
|
<span class="literal">int</span> status = (<span class="literal">int</span>) (Math.random() * <span class="number">3</span>);
|
||
|
<span class="literal">if</span> (status == <span class="number">0</span>) {
|
||
|
pane.add(<span class="literal">new</span> ImageView(imageX), j, i);
|
||
|
} <span class="literal">else</span> <span class="literal">if</span> (status == <span class="number">1</span>) {
|
||
|
pane.add(<span class="literal">new</span> ImageView(imageO), j, i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Create a scene and place it in the stage</span>
|
||
|
Scene scene = <span class="literal">new</span> Scene(pane);
|
||
|
primaryStage.setTitle(<span class="string">"</span><span class="string">Tic Tac Toe</span><span class="string">"</span>); <span class="comment">// Set the stage title</span>
|
||
|
primaryStage.setScene(scene); <span class="comment">// Place the scene in the stage</span>
|
||
|
primaryStage.show(); <span class="comment">// Display the stage</span>
|
||
|
}
|
||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||
|
launch(args);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
</pre></body>
|
||
|
</html>
|