Skip to content

Instantly share code, notes, and snippets.

View speters33w's full-sized avatar

Stephan Peters speters33w

  • Greene, Pennsylvania, USA
  • 23:30 (UTC -04:00)
View GitHub Profile
@speters33w
speters33w / KivaCreateMap.java
Last active July 5, 2022 18:02
ATA KivaWorld Random Map Generator - Generates random maps for the ATA KivaWorld project. Includes a robust Point class that includes reflection, and a handy String to text file with GUI method using JFileChooser.showSaveDialog
package solver;
//import kivaworld.FloorMap;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
@speters33w
speters33w / PoolPuzzleOne.java
Last active May 13, 2022 03:11
Pool Puzzle One from Head First Java, Second Edition. The Third Edition is coming soon! Fun with Java Loops NO SPOILERS!
/**
* Pool Puzzle
* Your job is to take code snippets from the pool and place them into the blank lines in the code.
* You may not use the same snippet more than once, and you won't need all the snippets.
* Your goal is to make a class that will compile and run to produce the output listed.
* Don't be fooled--this one's harder than it looks.
*
* Output
* %>java PoolPuzzleOne
* a noise
@speters33w
speters33w / MyThisTest.java
Last active April 26, 2022 20:24
this.keyword = keyword;
public class MyThisTest {
private int a;
public MyThisTest() {
this(42); // calls the other constructor
}
public MyThisTest(int a) {
this.a = a; // assigns the value of the parameter a to the field of the same name
@speters33w
speters33w / SimpleCalculator.java
Created April 26, 2022 15:06
Udemy Java Programming Masterclass Sum Calculator
public class SimpleCalculator {
private double firstNumber;
private double secondNumber;
public double getFirstNumber(){
return firstNumber;
}
public double getSecondNumber(){
return secondNumber;
@speters33w
speters33w / NumberPalindrome.java
Created April 20, 2022 20:06
Udemy Java Programming Masterclass Number Palindrome Challenge using StringBuffer
//Udemy
//Java Programming Masterclass covering Java 11 & Java 17
//Number Palindrome
//
//Write a method called isPalindrome with one int parameter called number.
//The method needs to return a boolean value.
//It should return true if the number is a palindrome number otherwise it should return false.
//Check the tips below for more info about palindromes.
//
//Example Input/Output
@speters33w
speters33w / WhileAndDoWhileStatements.java
Created April 20, 2022 00:59
Udemy Java Programming Masterclass Sum Odd and While and Do While Statements Challenge
//Udemy
//Java Programming Masterclass covering Java 11 & Java 17
//Sum Odd and While and Do While Loop Statement Challenges
//
//////////////////////////////SUM ODD//////////////////////////////
//
//Write a method called isOdd with an int parameter and call it number.
//The method needs to return a boolean value.
//Check that number is > 0, if it is not return false.
//If number is odd return true, otherwise return false.
@speters33w
speters33w / IsPrime.java
Created April 19, 2022 21:33
Udemy Java Programming Masterclass For Loop isPrime Challenge
//Udemy
//Java Programming Masterclass covering Java 11 & Java 17
//For Loop Challenge IsPrime
//
// Create a for statement using any range of numbers.
// Determine if the number is a prime number using the isPrime method.
// If it is a prime number, print it out AND increment a count of the number of prime numbers found.
// if that count is 3 exit the for loop.
// hint: Use the break; statement to exit
@speters33w
speters33w / NumberOfDaysInMonth.java
Last active April 19, 2022 19:11
Udemy Java Programming Masterclass Number of Days in Month Challenge (not using switch)
//Udemy
//Java Programming Masterclass covering Java 11 & Java 17
//Number Of Days In Month
//
//Write a method isLeapYear with a parameter of type int named year.
//The parameter needs to be greater than or equal to 1 and less than or equal to 9999.
//If the parameter is not in that range return false.
//Otherwise, if it is in the valid range, calculate if the year is a leap year and return true if it is, otherwise return false.
//
//A year is a leap year if it is divisible by 4 but not by 100, or it is divisible by 400.
@speters33w
speters33w / NumberInWord.java
Created April 19, 2022 17:57
Udemy Java Programming Masterclass Number in Word Challenge
//Udemy
// Java Programming Masterclass covering Java 11 & Java 17
// Number In Word
//
// Write a method called printNumberInWord.
// The method has one parameter number which is the whole number.
// The method needs to print "ZERO", "ONE", "TWO", ... "NINE", "OTHER"
// if the int parameter number is 0, 1, 2, .... 9 or other for any other number including negative numbers.
// You can use if-else statement or switch statement whatever is easier for you.
//
@speters33w
speters33w / PrintDayOfTheWeek.java
Last active April 19, 2022 17:02
Udemy Java Programming Masterclass Day of the Week Challenge and Bonus Challenge
//Udemy
//Java Programming Masterclass covering Java 11 & Java 17
//Day of the Week Challenge
//
//Write a method with the name printDayOfTheWeek that has one parameter of type int and name it day.
//
//The method should not return any value (hint: void)
//
//Using a switch statement print "Sunday", "Monday", ... ,"Saturday" if the int parameter "day" is 0, 1, ... , 6 respectively,
//otherwise it should print "Invalid day".