resource
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@558 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
f6d3039ac9
commit
08d3a19e0a
src/main/java/se/su/dsv/scipro/data/dataobjects
@ -1,7 +1,7 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
@ -57,7 +57,7 @@ public class Resource extends Ratable {
|
||||
|
||||
|
||||
@ManyToMany
|
||||
private Set<Tag> tagSet = new HashSet<Tag>();
|
||||
private List<Tag> tagList = new ArrayList<Tag>();
|
||||
|
||||
@Lob
|
||||
private String link;
|
||||
@ -70,13 +70,12 @@ public class Resource extends Ratable {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
|
||||
public Set<Tag> getTagSet() {
|
||||
return tagSet;
|
||||
public List<Tag> getTagList() {
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public void setTagSet(Set<Tag> tagSet) {
|
||||
this.tagSet = tagSet;
|
||||
public void setTagList(List<Tag> tagList) {
|
||||
this.tagList = tagList;
|
||||
}
|
||||
|
||||
public void setHeading(String heading) {
|
||||
|
38
src/main/java/se/su/dsv/scipro/data/dataobjects/Test.java
Normal file
38
src/main/java/se/su/dsv/scipro/data/dataobjects/Test.java
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] test = {5, 5, 5, 5, 10 };
|
||||
|
||||
int lowestDiffernce = 0;
|
||||
int count = 0;
|
||||
int pivotValue = 0;
|
||||
int firstValue = 0;
|
||||
for (int i = 0; i < test.length; i++) {
|
||||
firstValue += test[i];
|
||||
int sum = 0;
|
||||
for (int j = i + 1; j < test.length; j++) {
|
||||
sum += test[j];
|
||||
}
|
||||
if(count == 0){
|
||||
count++;
|
||||
lowestDiffernce = firstValue - sum;
|
||||
}
|
||||
if ((Math.abs(firstValue - sum)) < Math.abs(lowestDiffernce)) {
|
||||
lowestDiffernce = (firstValue - sum);
|
||||
pivotValue = i;
|
||||
}
|
||||
}
|
||||
System.out.println(pivotValue);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user