Skip to content

Instantly share code, notes, and snippets.

@SamuelSchwent
SamuelSchwent / DistanceTraveled.fxml
Created March 3, 2016 15:58
Java - Scene Builder Application 3
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane minHeight="200.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Challenge5.DistanceTraveledController">
<children>
<Label layoutX="69.0" layoutY="23.0" text="Speed (mph):" />
@SamuelSchwent
SamuelSchwent / TipTaxTotal.fxml
Created March 3, 2016 15:56
Java - Scene Builder Application 2
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="150.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Challenge4.TipTaxTotalController">
<children>
<Label layoutX="14.0" layoutY="14.0" text="Meal Cost: " />
@SamuelSchwent
SamuelSchwent / NameFormatter.fxml
Created March 3, 2016 15:55
Java - Scene Builder Application 1
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="350.0" prefWidth="300.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="Challenge3.NameFormatterController">
@SamuelSchwent
SamuelSchwent / DisplayItems.java
Created March 3, 2016 15:46
Java - Throwing and Handling Exceptions
package Challenge3;
public class DisplayItems {
public static void main(String[] args) throws InvalidUnitsException, InvalidPriceException {
RetailItem item1 = new RetailItem("Jacket", 12, 59.95);
RetailItem item2 = new RetailItem("Designer Jeans", 20, 34.95);
RetailItem item3 = new RetailItem("Shirt", 20, -24.95);
System.out.printf("Item 1: %s\nUnits: %d\nPrice: %.2f\n"
@SamuelSchwent
SamuelSchwent / Employee.java
Created March 3, 2016 15:39
Java - Inheritance Example
package Challenge1;
public class Employee {
//Fields
private String name;
private String number;
private String hireDate;
//Constructor
public Employee(String name, String number, String hireDate)
@SamuelSchwent
SamuelSchwent / Accounts.java
Created March 3, 2016 15:37
Java - Search Example
package Challenge3;
public class Accounts {
int[] accountNumbers = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850,
8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
1005231, 6545231, 3852085, 7576651, 7881200, 4581002};
public boolean checkAccount(int number)
{
@SamuelSchwent
SamuelSchwent / LargerThan.java
Last active March 3, 2016 15:28
Java - Arrays and Sort Example
package Challenge4;
public class LargerThan {
public String displayLarger(int[] numbers, int n)
{
String largeNumbers = "Numbers greater than " + n + " are";
for(int x = 0; x < numbers.length; x++)
{
@SamuelSchwent
SamuelSchwent / DisplayEmployee
Created March 3, 2016 15:19
Java - Overriding toString and this Example
package Challenge6;
public class DisplayEmployee {
public static void main(String[] args) {
//Ch3 Challenge 1 Get/Set & constructors
/*
Employee employee1 = new Employee();
Employee employee2 = new Employee();
@SamuelSchwent
SamuelSchwent / DisplayInventoryItem.java
Created March 3, 2016 15:10
Java - Aggregation Example
package Challenge2;
public class DisplayInventoryItem {
public static void main(String[] args) {
String description = "This is a large Bolt.";
double units = 13;
InventoryItem item1 = new InventoryItem(description, units);
@SamuelSchwent
SamuelSchwent / Countable.java
Created March 3, 2016 15:05
Java - Static Class Members Example
public class Countable
{
private static int instanceCount = 0;
public Countable()
{
instanceCount++;
}
public int getInstaneCount()
{