David Cone

Ranch Hand
+ Follow
since May 26, 2021
David likes ...
Eclipse IDE MySQL Database Windows
I was born in September, 1967. I', 6'4". I'm married.  She rocks! I've had all the toes on my right foot amputated. I'm working on being better fit physically and mentally.  The last job I had (outside helping my dad sell ukuleles online, before he died) was Network Engineer for Excel Agent Services (which went belly-up). I've been working with computers since the TRS-80 Model 1, level 1 with a whopping 4K of memory and 150 baud cassette tape for storage. Due to a number of reasons, I got out of computers around 1999. (Windows 2000 just came out, and the new Active Directory model over primary/backup domain controler servers) I'm back.
SoCal
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
10
Received in last 30 days
10
Total given
3
Given in last 30 days
3
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Cone

What I mean by reference ID:  In the code as is now, I have an object roomy and an object exRoomy.  From those object names I can keep a clear mental reference to which object refers to the object when he lived here and which object refers to when he went to fire-school.  If I moved to the model, that easy reference disappears.  While I have the code.... [scrolls back to look lup the spelling of the word] immutable, if I accidentally try and assign a new person to "exRoomy" Java will sound the buzzer.  So as the code is now, 1. I have meaningful names (to me) for my objects, and 2. I can't accidentally reuse an object name.  Both of those seem like features not bugs, particularly when I start writing larger programs. So even though adding new user objects (which I don't see happening in real life, but is serving as an example) is currently a two step process the advantages of doing it that way seems to out-weigh the disadvantages.  I do look forward to learning about these HashSets Paul (or you or maybe both) talked about.  For now, I'm trudging on through the course sequentially and doing all the code exercises, even if they are easy.  If nothing else, the repetition is helping me have less buggy code because "the Java way/syntax" is becoming a habit.

Campbell Richie wrote:This (old style guide link) is what you should write:-

 Yes between my last msg and reading yours I figured out that most boolean methods can just be the word return followed by boolean math.  I wrote some beauties last night or the night before.... both I guess.  My favorite was the leap year problem.  Mostly because it made me think.... I cut down my code several times...  I'd be working on a completely different problem and something about writing  the current solution would prompt me to realize I had redundant checks in my previous code.  I'm enjoying the course so far.  I did send in a query to the teacher  to see if it's OK to use things we haven't  officially been taught in our solutions (like the ternary operator, which is still a valid construct for non-boolean methods that return strings.)  

Thank you all for being awesome and have a way-cool rest of your weekend!
Peace out,
~d
21 hours ago
So I'd loose a reference ID (in this case, the variable name) by doing it in one step.....  and if I add a reference ID to the class, I have no way to ensure it's not duplicated (well I guess it's not impossible, just a bit over my head at the moment...  I was reading up on this at stackoverflow.com and I guess a new class could be made that extends ArrayList, override the .add method to include duplicate checking on the first property and if no duplicate is found, do a "super.add"...  That's all off the top of my head from what I read last night,  Let me see if I can find the reference...  brb.... [time passes] ... Solution Entry by G H...  I'm pleased to say I've read enough about Java that I understand what he's saying....  just not enough to program it.) I think I'll be satasfied with the code as it is for now.  Later I'll add the ability to read the data from a file.  For now I'm having fun doing code exercises on Udemy.com.  I had fun doing the "Barking Dog" exercise with a single if statement.  If we were allowed to do it using the ternary operator (which we haven't learned yet) the solution could be done in a single statement:   Off to code... Have a great evening!  ~d
2 days ago

Estel Lopez wrote:


So if your feeding 1 person, and rice, shrimp and squids each cost 1 €/kg, to feed that one person would cost 3 €?  

Before  you tackle the code part, I want to agree and support Mr. Campbell's assertion that before  you work on code, you need to know the process.  How would you solve this problem using a #2 pencil and a Big Cheif tablet paper.  In the end, if you don't know how to solve the problem without a computer, you'll never be able write the program to solve the problem with a computer.  On the contrary, the better you understand what method you would use to solve the problem "by hand," the easier it will be to write the program.

Are you taking this Java course online or in classroom?   How is the material taught:  lecture, videos, or some other form?  What resources are avalable to you in this course?  Is there a book?  What was the last topic of discussion before this assignment?
~d
2 days ago
You have an awesome teacher,  I love the problem.  I particularly like the calculating costs part of the exercise.  
3 days ago

Campbell Ritchie wrote:Something like?



I didn't look this up, but it's time to get more sleep (and I'm not sure what search terms to use).  Can I do something like ?

Thanks,
~d
3 days ago
@Campbell - brilliant as always!  Thank you good sir.  BTW, I noticed I got your advise indirectly.  If I offended you, I deeply apologize!   Oh, I did get some more sleep this afternoon.  Thank you for your concern.

@all -  With a cool post on stackoverflow.com (referenced in code comments) and Campbell's streamline, I got a new version of this program that uses ArrayList to print out the users.  I'm happy to say I got it working! (woot!)  Before I work on 2.0 which will be getting the list from a file,  I feel like there is probably some more streamlining to be done.  Which is to say I know your brilliant minds can do it more efficiently.... perhaps there's a way to create a new user and add them to UserSet in one shot.  For now I'm off to play some Bloons TD 6, and then I'll dive back into Udemy.com's program.  I'm happy to say I found the bug in the  teachers code (which he points oout in the next video) before watching the next video that told me about it.  I also found a streamline that he didn't mention.  I feel like I've made good progress today.   Oh yeah, before I go... the new code.

Address.java:


User.java:


Main.java:


Have a way cool evening/night,
~d
3 days ago
Version 1.2

Main.java;
4 days ago
@Junilu - fair enough.

@all - Is this up to standards?


Address.java:


User.java


Main.java:


thank you for your time,
~d




4 days ago
@Ritchie...  It's not as much "nightowl" as it is "Insomnia".  I did get a couple of hours sleep before I woke up again at ~11:30.pm.  I'm a huge fan of sleep.  I fully believe in it and seek a rested state every day.

@Fred I totally understand your house example, thank you good sir.

@anyone - I still don't get what an immutable program looks like.  Can anyone give me a side by side... a short program or snippet in mutable form and then the same thing in immutable form.  That would help me greatly.  If it makes it easier, what would an immutable version of a program I have already written looks like.  If you have homework fear, one of your own.  To quote my sister, this is all great in Theory, but I don't live anywhere near, Theory.

@Junitu. - No, I said it the way I meant it.  I felt like I was bringing mole-hill problems and getting mountain answers which don't cast well back into mole-hill.  Not angry, overwhelmed.  A dadism:  How do  you eat an elephant sandwich?  One bite at a time.  I keep trying to take a bite out of learning Java and people keep handing me back new sandwiches.  So instead of feeling like I'm making progress, I feel like I'm falling further behind.  In this case, I was trying to learn about objects stored in other objects.  Responses: "you need to understand immutability and formal programming"...  something you can write an entire book about...  something I wasn't aware that I wasn't aware of it.  Now it's in queue to learn.  A queue that feels like it's about to overflow.  And I get that people are sincere in there efforts to help and I 'm sure that in some cases bring up what they do will keep me from learning a wrong way and having to unlearn it, so I am appreciative. but that doesn't make it any easier for my head to wrap around the micro-topic that I'm working on at a given moment.  I do not choose to proclaim ADD or ADHD or any of those labels over myself.  However, I will admit sometimes it's hard to focus on one specific subject, so that adds to the dilemma as well.

Have an AWESOME day,
~d
4 days ago
@Ritchie  I've read that a couple times now. It's 3:48am and I need sleep.  I can't promise that tomorrow I'll try again, but I will someday soon.

@Paul I'm guess I got this figured out to a point that I'm satisfied... Here's my more realistic test code.

Address.java:


User.Java:


Main.java:


Output:

Dave Cone
1 Hard Dr
Santa Ana, CA 92707
And now for someone... completely different.

______

I'm Real
1 Hard Dr
Santa Ana, CA 92707
unreal!


===============


Dave Cone
1 Hard Dr
Santa Ana, CA 92707
And now for someone... completely different.

______

I'm Real
1 USB St
Riverside, CA 92505
unreal!

Process finished with exit code 0


Is that reasonable code for day 27 of learning Java?
4 days ago
Hi Paul,  (on a side note, I'm less cry-baby now)

My artistic aptitude is way low.  I don't even do stick figures well.  Someday I'll post some of my "artwork" for everyone's amusement.

Thank you ever so much for your explanation.  Let me try a few things using my new understanding and perhaps it is now a non-issue.

Thank you for being awesome,
~d


4 days ago
error in response: Cannot cast type mountain into type molehill.
4 days ago
Now that I'm a bit calmer,  let me try this again.

I updated my bio information on this site, if you want to know a bit more about me.  Maybe it will help you understand me a bit more. I also updated my signature.

I'm teaching myself programming.... I get I have a lousy teacher.  I'm also taking a Java course on Udemy.com (based on a recommendation by someone on this site)... we haven't even learned System.out.print yet (only println), but I'm choosing to go through the entire course anyways.  Part of what helps me trudge through the course is working on some of my own interests (which is what I'm doing now.)  I do plan on taking Java programming in college in the fall semester starting in August.  At that point any school related question will only be asked of people at the college. I have zero interest in having others do my homework.

The way I learn stuff best is to try and solve problems I think of that interest me.  I'm trying to learn about objects inside other objects.  I like to learn by example...  When I don't understand something about a solution I like to ask questions.  That's what seems to work best for me.  I fully understand that this approach may not work well for others.  I never claimed to be like anyone else.

I started learning Java (from a book) and from online examples back on 5/21/2021.  So today is day 26.  When you reply to  me, please keep this in mind.  I wonder how much of what people have told me today would have made sense to them on their day 26.

I started reading up on formal programming / immutability...  It seems useful, but it's all a bit above my head at this time.

I would very much appreciate it if someone could show me how to put the contents of an object into another object in such a way that if I update the first object, the 2nd object is not effected.

If you don't want to do that, I'm OK with it.... give me crickets.  If, however it adds to your life by showing me how this is done, that would be AWESOME and I would be grateful.  

Thank you for your time and consideration.

May you have a peaceful and rewarding day,
~d

4 days ago
OK, so I used the wrong language.  MY BAD!!! I apologize!!! (gee whiz)  How do I keep it from being muteable (or whetever)?
5 days ago
Obj1.java:


Obj2.java


Main.java


Output on my pc in IntelliJ IDEA Comm. E. 2021.1.2 x64:

"D:\Program Files\Java\jdk-16.0.1\bin\java.exe" "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2\IntelliJ IDEA Community Edition 2021.1.2\lib\idea_rt.jar=57951:D:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2\IntelliJ IDEA Community Edition 2021.1.2\bin" -Dfile.encoding=UTF-8 -classpath D:\Users\David\IdeaProjects\ObjectInObjectDemo\out\production\ObjectInObjectDemo com.user404.Main
          Object 1's integer is 1
Object 2's (object 1 integer) is 1
          Object 3's integer is 1
          Object 1's integer is 16
Object 2's (object 1 integer) is 16
          Object 3's integer is 16
          Object 1's integer is 8
Object 2's (object 1 integer) is 8
          Object 3's integer is 8
          Object 1's integer is 32
Object 2's (object 1 integer) is 32
          Object 3's integer is 32

Process finished with exit code 0


5 days ago