Jump to content

TF2 ToolBox [Java Help]


AwesomeMcCoolName

Recommended Posts

I'll help out for a key

 

EDIT: Actually no, I would actually help you for free, but I'm busy as fuck tonight with college applications so I can't.

Link to comment
Share on other sites

I'll help out for a key

 

EDIT: Actually no, I would actually help you for free, but I'm busy as fuck tonight with college applications so I can't.

Well i'll just post the 2 issues i'm having: 

 

1) 

String y = "1.33-1.66";

int index = y.indexOf("-");

if (index != -1){

System.out.println(y + "," + index); //tester

y = y.substring(index+1);

}

Why is index coming back as -1 if a "-" is in the string? 

 

2) How would i assign an entire text file to a string? 

Link to comment
Share on other sites

 

1) comes back as 1.33-1.66,4

 

Keep in mind that "–" (Dash) is not equal to "-" (Hyphen/Minus)

 

2) http://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file?answertab=votes#tab-top

i copy and pasted the "-" from the actual string yet it still comes back as -1.

Edit: nvm

 

 

And i saw that, but it didn't really help me figure out what to do :3 

Link to comment
Share on other sites

  • 3 weeks later...

Too lazy to make a new thread.....so

 

Given this string: "TR 1-WF 10-TR 12-R 3-MWF 1-MW 12-R 12-MW 2" [/size]

Whats the best way to filter out any conflicts? 

 

E.g. I need to look at all monday times and see if any are the same, then i need to look at all tuesday times and see if they conflict, and so on. 

 

So far i'm thinking: 

 

String mondayString = s;
int monday = mondayString.indexOf("M");
int spaceAfterMonday = mondayString.indexOf(" ");
String mondaySub = mondayString.substring(spaceAfterMonday, mondayString.indexOf("-")); //grab the time of the FIRST Monday slot
mondayString = mondayString.substring(mondayString.indexOf("-") + 1); //removes the first monday slot from the string
The only issue with that is i would have to make a new variable for each monday even, and i don't know how many monday events there are....although i could do an if statement to see if there are any mondays in the new string and if there are create a new variable and keep going until there are no more mondays, and then do the same for tuesday, etc...

 

 

//Not schoolwork

Link to comment
Share on other sites

Are you really sure, that's the way you want and need to represent data? How about some proper data structure?

i can.....i'm just too lazy too :3
Link to comment
Share on other sites

actually using any sort of data structure would be the lazy way

if you can explain the string format, I may be able to suggest you proper way of doing this...

 

anyways, to check for duplicates in constant time, you can use HashSet

Link to comment
Share on other sites

actually using any sort of data structure would be the lazy way

if you can explain the string format, I may be able to suggest you proper way of doing this...

 

anyways, to check for duplicates in constant time, you can use HashSet

Well, i'm writing a program which will list every possible combination of classes.

 

So right now, i have 8 strings each one is a "day/s time" and i'm writing each string into a large array which will store every class combination, and then i have two methods, one which filters out exact duplicates and the other which will filter out conflicts. So i'm thinking a quick and lazy way to do it would be to create an array for each class, pick a random index from each array, and then keep the objects in arrays and compare T arrays against other T arrays etc...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...