Skip to content

Instantly share code, notes, and snippets.

@ckob
ckob / Player.java
Last active June 22, 2017 05:00
Game
/*
* Program.java 1.0 11-02-2016
*
* Copyright 2016 Charly Koch Busquets <charlykoch@hotmail.com>
*
* This is free software, licensed under the GNU General Public License v3.
* See http://www.gnu.org/licenses/gpl.html for more information.
*/
package game;
public class Player {
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/login.css">
<title>Chang</title>
</head>
<body>
<div class="container">
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
public class Contact {
private int dni;
private String name;
private String phone;
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
import java.util.ArrayList;
public class Ferry {
private String regNumber; // Matricula del ferry
private String name; // Nom del ferry
private String harbourName; // Nom del port destí del ferry
private double pricePerAxle;// Preu en € que cobra el ferry al camió per cada eix
private double pricePerTon; // Preu en € que cobra el ferry al camió per cada Tm de pes
private double maxWeight; // Pes màxim en Tm dels camions transportables pel ferry.
private ArrayList<Lorry> boardedLorries; // Els camions carregats al ferry
Fitxer /var/lib/pgsql/data/postgresql.conf :
- listen_adresses='*'
- port=5432
(les dues anteriors descomentades)
Fitxer /var/lib/pgsql/data/pg_hba.conf:
(al apartat IPv4, afegir:)
- host all all 192.168.3.4/32 trust
(amb /32 només pot entrar el propi pc)
public int countWords() {
int totalWords=0;
for (String s : strFitxer) {
for (String i : s.split(" ")) {
if (!i.isEmpty()) {
totalWords++;
}
}
}
return totalWords;
public BookTxt(String filePath) {
this.filePath = filePath;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(this.filePath));
strFitxer = new ArrayList<>(5000); // 5k de linies inicials, falta buscar quantes serien més aproximadament a partir del tamany del fitxer.
String actualLine;
while ((actualLine = br.readLine()) != null) {
strFitxer.add(actualLine);
@ckob
ckob / filaCsvToArrString.java
Created April 25, 2016 17:39
Lector de csv
private char possibleDelimitadorCampsEntrada = '\"';
private char separadorEntrada = ',';
/**
*
* @param fila un string separat amb estil csv
* @return array de Strings amb un valor per cada camp separat correctament.
*/
public String[] filaCsvToArrString(String fila) {
ArrayList<String> strings = new ArrayList<>();
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
public class CSVUtils {