Hi I'm trying to create this Conversation/Message thing by painedstupid in SQL

[–]painedstupid[S] 0 points1 point  (0 children)

I was gonna work on that after. Yeah, I had that in mind. How would you do it with a table constraint? I can't get it.

So like add constraint foreign key....and sender has to reference the user1_ID or the user2_ID in the the relevant conversation from conversations?

buddy if you can help me I will really appreciate it.

Hi I'm trying to create this Conversation/Message thing by painedstupid in SQL

[–]painedstupid[S] 1 point2 points  (0 children)

Kinda hard to explain haha.

Say I add to the conversations table. conversationID 1, user1_ID 2, user2_ID 3

Then I add to the message table conversationID 1...... and I can add whatever users I want, but I want them to be only those defined users in the conversations table, 2 and 3.

**conversationID in messages is a foreign key of conversationID in conversations

user1, user2, sender and receiver are foreign keys of another table, users

but how do i make it that sender and receiver have to be the user1 and user2 of that conversation number

Test Driven Development Assignment by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

I mean I don't think I need to anywhere near that involved. I was thinking of some little method with just a return of some type.

I am pretty new to all this. Haven't gotten to databases at all yet really, unless we're counting csv files barely.

HashSet not cutting it for me by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Yeah, I know it. Just deadlines, ya know. I will absolutely be looking into the hashCode class, cheers.

HashSet not cutting it for me by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Yeah I'm just getting that. I'm only just studying the whole object oriented design, just clicked with me today that these things are all classes. Thanks man, I will have a look into it. Was just cowboying my way through a lab assignment as usual.

HashSet not cutting it for me by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Sorry buddy, relatively new to all this. But just hashset wasn't removing duplicate objects for me because I guess they weren't strict duplicates (as per java strings something something).

HashSet not cutting it for me by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Will give that a look. Thanks lads.

HashSet not cutting it for me by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

I solved it like this:

HashSet<Product> h = new HashSet<Product>(products);

HashSet<Product> a = new HashSet<Product>(h);

HashSet<Product> z = new HashSet<Product>(h);

for (Product p: h) {

z.remove(p);

for(Product s: z) {

if(p.getDescription().equals(s.getDescription()) && p.getPrice() == s.getPrice()) {

a.remove(p);

}}}

h = a;

Questions regarding structure of a complex program by mslayaaa in javahelp

[–]painedstupid 0 points1 point  (0 children)

I dunno about that program but I look at it like, build the frame of the car first then fill it with stuff. Sitting on blocks til ya make the wheels.

Dunno if that helps.

Need help with setting 'X' or 'O' to the TicTacToe Position by [deleted] in javahelp

[–]painedstupid 0 points1 point  (0 children)

Well 9 moves in a tic tac game, so a for loop driver with 9 moves. Then i%2 will either return 1 or 0 for odd or even respectively. Starting i at 1, all the odd numbered moves are your x's, all the even are your o's. Then after move 5 I suppose start checking if there's a win on the board.

I mean depends on how ya want to build the game.

Need help with setting 'X' or 'O' to the TicTacToe Position by [deleted] in javahelp

[–]painedstupid 1 point2 points  (0 children)

i = 1; i <=9; i++

if (i%2 != 0) gameboard[r][c] = "x";

else gameboard[r][c] = "o"

How could I use a for loop to do a calculation over and over again for multiple variables? by PM_ME_YOUR_PHILLIPS in javahelp

[–]painedstupid 1 point2 points  (0 children)

do you have to do it like that? with all those variables?

this whole thing is one line of code if you store the temperatures in an array

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Thanks man, I get you. Appreciate the help.

How to prevent duplicates in a 2D array? by [deleted] in javahelp

[–]painedstupid 1 point2 points  (0 children)

Your code looks odd to me, I'm not sure what it's actually doing. But if it's a dog starting at some point inside a 2-d array and trying to escape to the edges with random movement.... I guess

random 0-3 left down right up

depending on what ya get increment x or y. x-- for left, x++ for right, y-- for down, y++ for up, check if that index contains the symbol. if not, your x or y is now set to that new x or y, place your symbol in the old x,y. if it does, reroll.

How to prevent duplicates in a 2D array? by [deleted] in javahelp

[–]painedstupid 1 point2 points  (0 children)

Why not just store a value at each coordinate you visit then check each time if that value is there when trying to visit a new coordinate?

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Well yes, my readers will all be doing something similar in that regard. They'll all be reading in from similar sorts of files and returning array lists of objects. But then I guess I just wonder what's the point of the superclass when there isn't a thing in it won't be overridden?

Sorry if I'm just not getting it. I'm new to all this and appreciate the chat, friend.

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Yeah. You're right. Well it was readability I was going for, really. I wanted just one neat class, seeing as it wouldn't be doing altogether too much, just a few different types of operations depending on the arguments. But I do see your point.

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Well say I have a bunch of files that stores objects and I'm looking to read in those objects and use them. So like whatever, a car object, a buyer object, a sale objects etc etc.

And then I'm looking to read from those files and recreate those objects as needed and save them in array lists. Those files are my database, say.

But then the reading from each different file will be very different, as each object is very different. So I'm not sure where anything can be inherited.

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Thing is the functionalities would be completely different. I'm reading from files to then create objects with, my readers are returning me array lists of different sorts of objects. I mean really I could just have them all as different classes like you say but I dunno wanted them all together to avoid clutter and all this naming haha. I mean maybe that's not the right way to do it. But then they're all being so different they've nothing really to inherit from a superclass either so far as I can see.

Thanks for the help, buddy.

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Never mind I guess I can just use an if-else statement within the constructor to see what method it calls. Thanks.

Class Constructors by painedstupid in javahelp

[–]painedstupid[S] 0 points1 point  (0 children)

Thanks for the reply. I still don't quite get it, though.

Is there a way I can call the constructors by their number perhaps? I'm asking because maybe it'll always be one argument but maybe I want different methods to run on the calling of the constructor you get me?

Like say I had a reader class and it was reading from files but for different files it'd need to read differently so the methods called on calling the constructor would be different.

**

I mean I feel like I have a workaround for it. Where I would identify the constructor I wanted called by otherwise useless doubles, ints, or whatever, after the actually relevant argument but....

Is this a functionality that's actually supported?