Paul Clements

Ranch Hand
+ Follow
since Oct 30, 2016
Paul likes ...
Eclipse IDE MySQL Database Chrome
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
8
Received in last 30 days
0
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Clements

Tyrone Berhane wrote:is Encapsulation used to protect the code's Inheritance structure?


1. What do you understand by the term "Encapsulation"?
2. What relevance could the answer to 1  have on your original question?

7 years ago

Junilu Lacar wrote:The && operator only short circuits if the left side expression evaluates to false

My mistake. You are of course correct.

Junilu Lacar wrote:I'm not sure how you came to think that it does.

Human fallibility.
7 years ago

Liutauras Vilda wrote:I think better would have been to admit mistake as this explanation isn't correct too


Min = 5
Max = 20
Value given is x
x >= Min AND x <= Max is valid
x >= Min on its own is not enough as x >= Min could be 100000
Need to check both sides for a BETWEEN

If I've misunderstood the ops question fine. However, I'm only trying to help, Stan. Perhaps that should be the focus here.


7 years ago

Liutauras Vilda wrote:Not sure why you were using not a short-circuit operator, but rather '&'.


Because I thought the OP was attempting to check within a range i.e. BETWEEN two numbers. As such a short circuit operator would be wrong as it would not check both sides.  I thought he had somehow set his own MIN and MAX. Time to move on I think.
7 years ago

Liutauras Vilda wrote:]What you can say about 'if' statements? Are they really need to be 'if' in all cases? At least one I see a good candidate to swap it to 'else'


Couldn't you remove one of the 'If' statements completely:
can become
7 years ago
Thanks for the reply. Very interesting.

One thing which comes across to me is that "Functional Programming" seems to be a distinct branch of Java programming, and less of a tool to be used within a standard OO program. Talk of "Functional Programmers" adds to this perception. Is this how you see it?

Paul.
Pierre-Yves,

Welcome to the forum and congratulations on the publication of your book.

I am new to Java, but not to programming (over 25 years experience). As such I have two quick questions:

1. Function and functional are such generic programming terms. What specifically do they mean/give to the Java developer?
2. Did functional programming exist in Java before Lamdas i.e. are Lamdas a formal response to something which was already happening or is functional programming a new concept in Java?

Cheers,

Paul.

Stan Austin wrote:Sorry im not sure i get this, been toying with it for the last 10 mins and I'm getting nothing


If manage.java contained this:
it would return:

1000
1010
990


Do you understand this code and output?
7 years ago

Liutauras Vilda wrote:There are always a lot to do, start writing code is the latest part you need to sit down and engage to.


You're ahead of where I want to be. At the moment I don't have any ideas. Really just wanted some feedback on:

1. Is this a good area for a project. The answer seems to be yes, which is what I was hoping.
2. Set up i.e. tools need to start building a basic web app. Are we really just talking about Eclipse to start with for something very simple? By simple I might mean possibly a single page which has a background image, some intro text etc and then has options to run currency converters/weather web services - that sort of thing. Really just to get up and running with the absolute basics of developing a website around Java.

Don't want help with Code. Just any general pointers, things to avoid, pitfalls, warnings around web dev for a relative novice.

Cheers,

PaulC.
7 years ago

Stan Austin wrote:however if i try to print "Employee.salary" it tells me salary is private!


Yes. That's called "encapsulation". It means keeping instance variable private and only allowing manipulation though the classes own methods i.e. what are commonly known as setters and getters. The getter on 'Salary' is salary(). Therefore if from within manage. java you create an Employee instance called e1 then e1.salary() should return what's held in 'Salary'.
7 years ago
Was looking through some Java job adverts today and one caught my eye. It was looking for:

* Java
* Javascript/HTML5/CSS3
* Spring/Hibernate
* MongoDB, SQLServer

This clearly sounds like a web based development opportunity. Don't worry, I'm not applying! However, what this triggered was an idea for a project. The reasons it appeals are:

I like developing on the web
I understand and can use/create web services
I have basic HTML and CSS skills
Have touched base briefly with JavaScript and have plans to dig a bit deeper
Know SQL Server (using relational DBs for years)
Spring/Hibernate/MongoDB are things I see a lot on ads

Ok. So now I've decided that what I want to do, are there any pre-requisites? Can I just jump in a create an extremely simply web site/app as a prototype? A quick look on Google suggested I needed the EE version of Eclipse, so I've downloaded that. Plan is to create something very simple to start. End goal is to develop a fully functioning web site/app, hopefully with web services integrated in.  

Does this seem a solid idea of a project to showcase some skills? Any tips to get me started i.e. environment set-up etc?

PaulC.
7 years ago
Stan, keep it simple. One step at a time i.e.

Create manage.java
Within it create an instance of an Employee
Apply a Bonus to the instance created
Show the result
Apply a Penalty to the instance created
Show the result

Build slowly on something which works. Don't get lost thinking too far ahead.
7 years ago

Stan Austin wrote: it must not be edited


It needs to be edited as line 42 is wrong. It should be:
That apart, you have been asked to:

Create your own program called Manage; Manage will have 4 functions


So you need a file called manage.java, which does some "stuff" with employees

1. change the employees income by applying a bonus or penalty.


Sounds like this involves creating some employee instances and then changing the initial income value (which appears to be 0 or some constructor value). You would change the salary by running the bonus or penalty method on the instances you want to change i.e. like the employee class does in its own main section (presumably there for unit testing)

2. take an array, of employees returning a boolean if two names match


There is an override of the Object equals method to do this.

3. return the total sum of all salaries in an array
4. print the name which is first alphabetically


Create an Employee array variable
Populate with some Employee instances
Process it within an enhanced for loop and sum the salaries retrieved via the Salary method
Sort list and display first entry

All looks straight forward. First and foremost, create your manage.java file and go from there.

7 years ago

fred rosenberger wrote:you guys missed the most obvious. The first example creates an array where the 2nd and 3rd elements are the same. The second example creates an array where all four elements are distinct.


Ha ha...true. Looks like a case of assuming the data was the same based on the way the question was phrased.
7 years ago
Lol, this was a subtle one :-) Look at line 8.

ps. You should indent your code properly to make it more readable.
7 years ago