Hello,
I've this question from an assignment to create a Store which rent out books, using a Store.java and Book.java. I've finished this assignment, but I'm curious for better algorithm to a specific part.
--
Book.java
public class Book {
private String name;
Book(String name)
this.name = name;
public String g...
Hi All,
I'm trying to submit a form to a different location depending on which (of two) form fields have been filed in.
It work when both fields have a value but when only one if field has a value it always submits to the suppliers/category/ URL. Here is my code.
$('#suppliersForm').submit(function() {
catVal = $('#category').val()
k...
I am looking to create an IF ELSE statement that says IF You reach the end of the UL LI, unbind click function from scroll button, ELSE bind click funtion
$(document).ready(function () {
$('#down').click(function () {
$(".project_thumbs").stop().animate({
"top": "-=510px"
});
});
$('#up').click(...
I am looking to create an IF ELSE statement that says IF You reach the end of the UL LI, unbind click function from scroll button, ELSE bind click function
$('#down').bind('click', function() {
$(".project_thumbs").stop().animate({"top": "-=510px"});
});
$('#up').bind('click', function() {
$(".project_thumbs").stop().animate({"to...
I'd been told, that using "if" statements is preferred , because of harder debugging of the code, when "else if" is used? Is there a grain of truth in this statement?
...
I'm attempting to write a java program that initializes certain layouts based on what the user selects. What I want to do is try to avoid writing a bunch of if-statements so the code can be scalable for future use if more layouts need to be added. I heard the best way to implement this is using polymorphism but my understanding of polymo...
I have this while loop in xcode. The loop seems to work fine since I printed my i++ in console. But for some reason it only checks my IF statement the first time around. I can only add one title into the MutableArray called sectionZeroTitleArray. I have many arrays in this loop so it might get confusing. I will try my best to explain.
...
Pretty simple question. I know it would probably be a tiny optimization, but eventually you'll use enough if statements for it to matter.
EDIT: Thank you to those of you who have provided answers.
To those of you who feel a need to bash me, know that curiosity and a thirst for knowledge do not translate to stupidity.
And many thanks t...
I basically want to check if part of a string begins with a certain sequence - in this case ftp://, or http://. How would I do this?
Thanks
...
I'm still somewhat a beginner to PHP, so sorry if this is a dumb question =)
What I'm trying to do is in a WordPress blog, insert a custom field with multiple values ("ingredients") into my RSS feed. (I also have other posts which are not recipes, which is why the headings "Ingredients" and "Instructions" are inside the if statement.) H...
Hi guys,
I have a registration form where a customer selects their desired package via a dropdownlist. They then select whether they wish to avail of a multiyear discount by choosing Yes or No radio buttons. If the yes radio button is selected, a dropdownlist is shown (using javascript) with a selection of years 1-3.
I'm not familar a...
Hi,
have this line:
if($('#address_nations_id').val() != 105 && $('#address_nations_id').val() != 74)
Is there any way to make it shorter?
I tried this:
if($('#address_nations_id').val() != 105 && != 74)
But it doesnt work.
Any idea?
Regards
Javier
...
I currently have a Quartz.NET job listener for all executed jobs so they can be auditted to a table ,which is working fine. But I also need to do something else if the job fails to execute for some reason. How can I check if the job has failed in the JobListener?
Thanks
...
Hi all,
I'm running a C# program (console application, soon to be converted to a Windows Service) where I need to be able to email administrators about errors in the service, but I need it to not send our an email for every error if the number of errors in the last few minutes exceeds 4-5, so it'll only send one email saying there are m...
I am attempting to write this html in haml so as to add an id tag if the item is the current one. This is to setup for jquery highlighting.
<% if line_item == @current_item %>
<tr class="line_item id="current_item">
<% else %>
<tr class="line_item">
<% end %>
<td><%= line_item.quantity %>×</td>
<td><%= line_item.product.titl...
I have a stored procedure that will INSERT a record into a table. I have created a unique key constraint on the table to avoid duplicate records.
Regardless of the fact that there is a unique key constraint defined, I am using an IF() condition (prior to the INSERT statement) to check for a duplicate record that may already exist.
How...
I have a very long conditional statement for deciding what action to take for a pair of variables a and b.
action = 0 if (a==0) else 1 if (a>1 and b==1) else 2 if (a==1 and b>1) else 3 if (a>1 and b>1) else -1
While it is nice with the compactness (in lines;) ) of this statement, it must exist a more elegant way to do this?
...
Hi,
I'm trying to write a regex which should be able to identify boolean expressions.
I need to avoid cases like IF(AND AND AND). The name of the variable shouldn't be one of the following operators (OR;AND;XOR).
I tried to use [^(OR)] but this wasn't helpful. My Regex looks like this:
(?:<Name> [A-Za-z0-9])
Is there any chance t...
Hi,
I have a problem here, Basically. .
I have a loop which has a list of sites, im going through each and every site.
I have another loop which only contains some sites
I want to return only the sites where the attribute t.title == F.title
If this is true I want to tick a check box
if not then dont tick a check box
The problem ...
Which of the following is a better way to structure nesting of If statments.
if (x && y)
doXY();
else if (x)
doX();
else if (y)
doY();
(OR)
if(x)
if(y)
doXY();
else
doX();
else if(Y)
doY();
...