Commit 3e7bf927 authored by Niklas Leivestad's avatar Niklas Leivestad
Browse files

initial commit / task 1

parents
.idea
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.ntnu.idatg2001</groupId>
<artifactId>oblig3</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>no.ntnu.idatg2001.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
module no.ntnu.idatg2001 {
requires javafx.controls;
exports no.ntnu.idatg2001;
}
package no.ntnu.idatg2001;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* JavaFX App
*/
public class App extends Application {
@Override
public void start(Stage stage) {
var javaVersion = SystemInfo.javaVersion();
var javafxVersion = SystemInfo.javafxVersion();
var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
var scene = new Scene(new StackPane(label), 640, 480);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
\ No newline at end of file
package no.ntnu.idatg2001;
/**
* Represents a playing card. A playing card has a number (face) between
* 1 and 13, where 1 is called an Ace, 11 = Knight, 12 = Queen and 13 = King.
* The card can also be one of 4 suits: Spade, Heart, Diamonds and Clubs.
*
* @author Niklas Leivestad
* @version 14.04.2021
*/
public class PlayingCard {
private final char suit; // 'S'=spade, 'H'=heart, 'D'=diamonds, 'C'=clubs
private final int face; // a number between 1 and 13
/**
* Creates an instance of a PlayingCard with a given suit and face.
*
* @param suit The suit of the card, as a single character. 'S' for Spades,
* 'H' for Heart, 'D' for Diamonds and 'C' for clubs
* @param face The face value of the card, an integer between 1 and 13
*/
public PlayingCard(char suit, int face) {
this.suit = suit;
this.face = face;
}
/**
* Returns the suit and face of the card as a string.
* A 4 of hearts is returned as the string "H4".
*
* @return the suit and face of the card as a string
*/
public String getAsString() {
return String.format("%s%s", suit, face);
}
/**
* Returns the suit of the card, 'S' for Spades, 'H' for Heart, 'D' for Diamonds and 'C' for clubs
*
* @return the suit of the card
*/
public char getSuit() {
return suit;
}
/**
* Returns the face of the card (value between 1 and 13).
*
* @return the face of the card
*/
public int getFace() {
return face;
}
}
\ No newline at end of file
package no.ntnu.idatg2001;
public class SystemInfo {
public static String javaVersion() {
return System.getProperty("java.version");
}
public static String javafxVersion() {
return System.getProperty("javafx.version");
}
}
\ No newline at end of file
package no.ntnu.idatg2001;
import junit.framework.TestCase;
public class PlayingCardTest extends TestCase {
public void testGetAsString() {
}
public void testGetSuit() {
}
public void testGetFace() {
}
}
\ No newline at end of file
Markdown is supported
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