Skip to content

Instantly share code, notes, and snippets.

View luchtech's full-sized avatar
🏠
Working from home

James Carlo Luchavez luchtech

🏠
Working from home
View GitHub Profile
@luchtech
luchtech / Valid.java
Last active August 21, 2018 07:08
Validator for Inputs from User
import java.util.ArrayList;
import java.util.Vector;
public class Valid {
/*
* This user-defined class is made by James Carlo Luchavez.
* This class is composed of the following Data Validating Methods:
* (a) "isDuplicate" returns the index of the given data from the array - Vector, ArrayList, Normal Array
* (b) "removeExcessSpace" returns a lowercase string with only one space from each word or element
* (c) "firstLetterUp" returns a string with first letters of each word capitalized (for names)
* (d) "toInteger" converts a string value to integer
@luchtech
luchtech / MyFirstJFrame.java
Created August 21, 2018 06:17
Simple JFrame Demo
import javax.swing.JFrame;
public class MyFirstJFrame extends JFrame {
public MyFirstJFrame() {
/*
* There are two ways to set the Windows title of the JFrame
* One is by passing a string to the "super constructor".
* The other one is using the "setTitle" method.
*/
@luchtech
luchtech / GUISum.java
Created August 21, 2018 07:07
Sum of Two Numbers (GUI)
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class GUISum extends JFrame{
@luchtech
luchtech / ArithmeticOperations.java
Created August 21, 2018 07:09
Arithmetic Operations (GUI)
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class ArithmeticOperations extends JFrame {
/*
* Only 3 Swing Components are required in this activity namely:
@luchtech
luchtech / SMS.java
Created August 21, 2018 07:17
SMS (Constructors, Setters, Getters)
public class SMS
{
private String inbox[];
private int smsCount, capacity, balance;
SMS(){
capacity = 10;
inbox = new String[capacity];
smsCount = 0;
}
SMS(int capacity){
@luchtech
luchtech / PhotoCopier.java
Created August 21, 2018 07:24
Real-Life Processes (Constructors, Setters, Getters)
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
@luchtech
luchtech / BowlingGame.java
Created August 21, 2018 07:51
Laboratory Activity: Selection Structure
import java.util.Scanner;
public class BowlingGame {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Program: BOWLING SCOREBOARD\n");
int score, total1 = 0, total2 = 0;
try{
System.out.println("\nFirst Try\n");
@luchtech
luchtech / EvenNum.java
Created August 21, 2018 07:59
Laboratory Activity: Loop Structure
import java.util.Scanner;
public class EvenNum {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Program: EVEN NUMBERS FROM 1-50\n");
System.out.println("Even Number from 1 to 50...");
System.out.println("----------using for loop----------");
for(int i = 1; i<=50; i++) {
@luchtech
luchtech / numberManipulation.java
Created August 21, 2018 08:08
Laboratory Activity: Methods
import java.util.Scanner;
public class numberManipulation {
static String DecToBinary(int num) {
if(num <= 0) return ""+num;
String hold = "";
while(num!=0) {
hold = (num%2)+hold;
num/=2;
@luchtech
luchtech / Magic.java
Created August 21, 2018 08:24
Laboratory Activity: List and Sorting Algorithm
import java.util.ArrayList;
import java.util.Vector;
public class Magic {
// DUPLICATE CHECKERS
static boolean isDuplicate(String s, Vector<String> arr) { // String Array
for(String x: arr) {
if(x.equalsIgnoreCase(s)) {
return true;
}