Liutauras Vilda wrote:Welcome to the Ranch and enjoy the stay. -Thanks
Jaredson Fetiza wrote:We have not really covered classes,methods or objects yet. Our professor evaluates us based on how we use what was taught in class.
Jaredson Fetiza wrote:I am not supposed any methods, classes or anything object related
Jaredson Fetiza wrote:How do I create new values for the same hashmap without overwriting the previous inputted hashmaps?
Overriding happens when you have the key you are about to add already added to a map.
For instance
Jaredson Fetiza wrote:Yeah but I cant create new keys and value with my approach (not that I know of) because it is a loop using the same hashmap.
Jaredson Fetiza wrote:I am experimenting with the hashmaps methods rn like clone(), keyset(), clear() or values to somehow see if I can get around that.
Liutauras Vilda wrote:Why? Could you give an example please.
What sort of course is this?Jaredson Fetiza wrote:. . . We have not really covered classes,methods or objects yet. . . .
Campbell Ritchie wrote:What sort of course is this?
Jaredson Fetiza wrote:
Liutauras Vilda wrote:Why? Could you give an example please.
Because I need to create a new one each time it loops?
- like this
Am I doing it right? What did you have in mind?
Honestly I am willing to start over from scratch cause I feel like it shouldn't be this complicated and there is a simpler approach of doing this haha
What you said makes me wonder whether you been taught any object‑oriented programming. I presume you have attended all the teaching.Jaredson Fetiza wrote:. . . Computer Science?
Liutauras Vilda wrote:
So what I was thinking of (and that is purely to work on the structure you laid down with Map<String, Map<String, String>>):
But again, I'm not entirely sure what you can use in your assignment. It doesn't say that you are not allowed something, nor it does say what you are allowed. Only you said you are not allowed that and that. So I'm not sure.
There are several meaning for the word “overriding”. It is commonly used about methods in object‑oriented programming, but Liutauras is using it differently. If you look in the Java™ Tutorials, you will see it says a Map “models the mathematical function abstraction”. Your map constitutes a function where x ↦ y and you are overriding a mapping in the function so that x ↦ z.Liutauras Vilda wrote:. . . Overriding . . .
Jaredson Fetiza wrote:Wait I don't get it. Isn't this what I am trying to do? Except that the main problem is I cant do what's in your comment.
I think the above is dreadful design, but it should work. Lines 7‑12 create a Map as an anonymous class; the calls to put(...); should populate the map with all the data you require, so use as many put(); calls, or as few, as you need.Jaredson Fetiza wrote:. . . Isn't this what I am trying to do? . . .
If you use the same value repeatedly, you will have every key pointing to that value. Adding pairs to it will change the state of the value, but not which object corresponds to y above.Half an hour ago, I wrote:You can use the same key as often as you like . . .
Campbell Ritchie wrote:overwrite
Jaredson Fetiza wrote:This is the instructions for the task if it helps.
Create a student database program that stores student records, which consist of:
Student ID
Full name
Age
Gender
Course
Year enrolled
Or they would if they actually taught tobject‑oriented programming. I had the good fortune to be taught by somebody (Elizabeth Norvall) who actually taught object‑orientation.Carey Brown wrote:. . . a Student object . . . Any other way . . . would . . send me off into the woods screaming. . . . they are telling you to create a Student object.
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|