Skip to content

Instantly share code, notes, and snippets.

View joopeed's full-sized avatar
:shipit:
shipping code around

João Pedro Leôncio joopeed

:shipit:
shipping code around
View GitHub Profile
public void setCurrentGame(Game currentGame) throws Exception {
if(!games.contains(currentGame)) throw new Exception("This game does not exist in the system");
this.currentGame = currentGame;
}
public void add(Game game) throws Exception{
if(games.contains(currentGame)) throw new Exception("This game does not exist in the system");
games.add(game);
}
package lp2.lab08;
import java.util.ArrayList;
import java.util.Collections;
/**
* Representa uma disciplina convencional
* @author João Pedro Leôncio <joopeeds@gmail.com>
*
*/
/**
* Devolve um item de um usuario a outro
*
* @param EmprestadorID
* Id do usuario emprestador
* @param EmprestadoID
* Id do usuario que recebe o item
* @param ItemID
* Id do item
* @throws Exception
package lp2.lab07;
public class Item {
private String ID, descricao, IDdono;
public Item(String ID, String descricao, String IDdono) throws Exception {
setID(ID);
setDescricao(descricao);
public double cofactor(int ii, int jj){
return Math.pow(-1,ii+jj)*(this.submatrix(ii,jj)).determinant();
}
public Matrix cofactorMatrix(){
double[][] comatrix = new double[ this.data.length ][ this.data[0].length ];
for(int i = 0; i < this.data.length; i++ ){
for(int j = 0; j < this.data[0].length; j++ ){
comatrix[i][j] = this.cofactor(i,j);
}
public boolean isUpperTriangular(){
for(int i = 0; i < this.data.length; i++){
for(int j = 0; j < this.data[0].length; j++){
if( i<j && data[i][j]!=0 ) return false;
}
}
return true;
}
public Matrix multiply(Matrix m2){
double[][] matrix2 = m2.getArrayMatrix();
double[][] product = new double[this.data.length][matrix2[0].length];
for(int i = 0; i < this.data.length; i++){
for(int k = 0; k < matrix2[0].length; k++){
for(int j = 0; j < this.data[0].length; j++){
product[ i ][ k ] += data[ i ][ j ]* matrix2 [ j ][ k ];
}
}
public boolean isInside(Point pt){
int intersections = 0;
int in=0;
for(int i=0; i < this.edges.length; i++ ){
if (edges[i].isLeft(pt)) intersections++;
if (edges[i].belongsToLine(pt) && !edges[i].isVertical()
&& pt.getY() <= edges[i].upperLimit() && pt.getY() >= edges[i].lowerLimit()) in++;
}
if(intersections==0 && in==1){
@joopeed
joopeed / toString.java
Last active December 11, 2015 18:59
toString
@Override
public String toString(){
String a_s = String.format("%.1f", a);
String b_s = String.format("%.1f", b);
if (b>0) b_s = "+"+b_s;
else {
if(a==1){
if(b!=0)
return "y = x "+b_s;
else