Kalabaw moo

Ranch Hand
+ Follow
since May 26, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kalabaw moo

I couldn't understand what you mean by regular class with a manager class. Please give a hint or explanation.
14 years ago
Thanks for the reply. I'm actually creating an application. However, what if I added a new type of user on runtime, let's say Group Admin that will have a different level of access. How do I update the enum with that type of user on run time?
14 years ago
I have been trying to create a program that will have 3 types of users. Super user (have all access), Admin(Add and modify record), end user( viewing records). However, I was advised that there will be an option to add a new user type (ex. Group Admin, Department Admin ) that will have a different level of access.

I have created an application and I'm finishing the login feature. I was having a hard time determining the user type and the appropriate access for them. The code below doesn't seem to resolve my problem, because what if on run time, I added "Group Admin" or "Department Admin"? the code below doesn't make sense. Please advice.

14 years ago
Sorry I forgot to edit that code I actually did your advice from your previous replies but that was applied to a different class not to that class. I wasn't using the Pair class just yet, I just got that idea in your previous post but don't know how to use it just yet. I don't actually need to sort the elements in any particular order I just want them to appear as they were input by the user so I used List. My friend told me that the elements of SET A must be unique so I can use the Set class but the problem it's not displaying the order the way the user entered the elements so I ended up using List. I edited the processCartesian to this:



I will update the code after work.

I'm confused about the question in question 4: What makes me confused is the part: ask the user to input a set isn't it referring to the defined set I just created in question 1 or I have to input ( define ) a new set?


If user chooses[4], the program asks the user to inputs a set and the program determines if it is a function. If a set has not been defined yet, the program should display the message “Sets are still undefined”.




I don't know if I understood Question 4 correctly, I was thinking that I will input a new set except the set I defined from question 1 to determine if it's a function, I guess it's wrong?

Or I will just pass the Set I defined from Question 1 to the method isFunction to determine if it's a function and I don't need to input a new set, I guess this is what the question really meant?
14 years ago

This is my answer to question 1 - 3 can you please check if there's any correction.. I'm still working out on question 4 and 5..
14 years ago
I have created a Pair class on my own but I don't have an idea on how to use it in my program.


Anyway, The program I created would ask me to input elements for Set A and Set B then it will produce the Cartesian product of the two sets


How many elements for Set A? 3
Enter element for Set A: A
Enter element for Set A: B
Enter element for Set A: C

How many elements for Set B? 2
Enter element for Set B: 1
Enter element for Set B: 2

Sets are now defined.
The cartesian product is: AXB = { A, 1}, { A, 2 }, { B, 1 }, { B, 2 }, { C, 1 }, { C, 2 }
==========================================================



Now I'm stuck with question 3: where will I get the set I'm going to input to determine the set if it is a function or not? from the cartesian product? or from Set A? or from Set B? same question with question 4.
14 years ago
Ok thanks, I'll be finishing my program tomorrow I have to finish something at work.
14 years ago


I'm sorry, where did you get the Pair class?...

edit: oh, I guess I'm going to creat my own generic class Pair with two parameter type.
14 years ago
don't have any problem here. You should use .equals() or .equalsIgnoreCase() of the String class if you're going to compare the contents of the String.

14 years ago


I've changed the code a bit and followed what you've advised ( I don't know if I followed it 100% ). I guess the method I created is not smart enough to check if the sets input by the user is a function or not.


If user chooses [1], the program prompts for the elements of the sets:

How many elements for set A? 3
Element 1: A
Element 2: B
Element 3: C

How many elements for set B? 2
Element 1: 1
Element 2: 2

The sets are:
A= {A,B,C}
B={1,2}

If user chooses[2], the program displays the sets. If a set has not been defined yet, the program should display the message “Sets are still undefined”.

If user chooses[3], the program displays the Cartesian Product of set A and B. If a set has not been defined yet, the program should display the message “Sets are still undefined”.

If user chooses[4], the program asks the user to inputs a set and the program determines if it is a function. If a set has not been defined yet, the program should display the message “Sets are still undefined”.

If user chooses[5], the program asks the user to inputs a set and the program determines if it is a relation. If a set has not been defined yet, the program should display the message “Sets are still undefined”.



I was able to answer Question 1, 2 and 3.

I am assuming in Question 4 that the elements to be inserted by the user will come from the sets I defined in question 1 ( or maybe not? ) and it should display if it's a function. According to the article I've read I can only determine if it is a function if in one input there is only one output.

e.g. { A, 1 }, { A, 2 }, { B, 1 }, { C, 1 } <- I understand this is not a function because A has 2 output 1 and 2.



I created this condition to check if there is a duplicate input so if there's a duplicate input the program will assume that it's not a function otherwise a function but I don't know if what I thought is correct. ( I'm totally confused now haha! I guess I just have to clarify Question 4 where does the user will get the input? the user will choose from the sets defined in Question 1 or the user will just enter what he/she wants to form a set to know if it's a function or not?)

If the the user's input will depend on the set defined in Question 1 now I can't think of any idea on how to make my method smart enough to check if it's a function or not. any idea? I'll be reading more about Maps and HashTable while waiting for a reply here.. thanks..
14 years ago


This is the method I created using hashmap I guess this could be minimized but it's working as I expected. I can't use Map because I can't do duplication so I just used HashMap.
[edit]I didn't read the tutorial about HashMap I just looked on the documentation and used it. I presume I used HashMap the wrong way?
14 years ago
Wow, after reading the documentation of Hashmap I already formulated an idea on how to solve my problem. I'll try to read Map as well maybe it'll be easier to what I'm thinking right now... thanks everybody..
14 years ago
thanks, I'll check on that..
14 years ago
I am doing a homework, I created a program that will ask the user to input the elements of set A and B and provided a feature that will display the cartesian product of the two sets as well as the elements of both sets. I understand question four and five but I'm having a hard time thinking of an idea to do it in my program. I know the concept to determine if the given set is a function or not.


if I input:
set A = [ A, B, C ] are the elements
set B = [ 1, 2 ] are the elements

if I input this like what is asked in question 4:
(a, 1), ( b, 1), ( c, 2 ) - this is a function.

if I input this:
(a, 1), ( a, 2), (b,2) - this is not a function

If user chooses[4], the program asks the user to inputs a set and the program determines if it is a function. If a set has not been defined yet, the program should display the message “Sets are still undefined”.


The problem is how will I scan those elements to check if it's a function or not, what i'm tinking is to use a string tokenizer or just put them into an array and scan them one-by-one to determine if it's a function or not or is there any package in java that can compare the elements of list 1 to list 2?



14 years ago