Larry Frissell

Ranch Hand
+ Follow
since May 16, 2008
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
3
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 Larry Frissell



The method above would give you a compile error since "list" is a simple array of GroceryItemOrder. Your add method needs to be corrected, to put the item into GroceryItemOrder[num] and increment num .
5 years ago

Now this is the point at which I am trying to figure out what to do next. How to isolate the top K elements without a sort?



What I did was to get the next number, ie 10. Then compared to topKList one at a time.
If topKList[0] was less then "10" I made a tempVariable = topKList[0] replaced the topKList[0] with 10.
Then continued through topKList comparing tempVariable to topKList[i] to ensure that tempVariable (the number that would be discard) was the smallest.

Yes, it would have been easier to sort topKList, but the problem stated was not to use sort.
5 years ago
Jeff is correct when he says that it is incremented, you can check that by using a print statement in the constructor like this will show you that i has changed. But it is not the same as h1.i.


5 years ago
As Winston said, using pencil and paper to find a solution is the best way to solve the problem. With that in mind, my solution (without sorting) is to consider the problem as a stack of cards with numbers on them face down. I can look at a card and decide to keep it or discard it. So I could keep the first three. After that each card I pick up I would then make the decision to keep the card or discard based on whether one of the cards I am holding is a lower value then the one I am looking at. After looking at each card in the stack once, I am holding only the three highest cards. Then it is simply a matter of selecting the smallest of the three.
5 years ago
I have found my answer to the code snytax at cupsofcocoa
It is based on the C structs format shown below.

Initializing Structures
The fastest way to initialize a structure is to enclose the values in a pair of braces:

Date today = {5, 22, 2011};You can list fewer values, and they will be filled in until the end of the values you list. The remaining values will be undefined.
Date today = {5};This sets the month to 5, but leaves the remaining fields with garbage values from RAM.
You can also initialize the values out of order:
Date today = {.day = 22, .month = 5; .year = 2011};



5 years ago
iOS
I am reading IOS 5 Developer's Cookbook by Erica Sadun. In the line of code below, I am trying to understand why there is a dot before "size". I know that "size" is a property of CGRect, and I understand how to use the "dot" for something like frame.width, but the syntax below appears to be different.

5 years ago
iOS
You can not have New Xuxu ( a non-staitic variable) in a static context (the main method)
6 years ago

I am using the code above without an error.
7 years ago
The program as written will not compile. Your switch statement has switch(C). You need to have one of the following primitive data types: byte, short, char, and int. That means you will need to have something like switch('C'). Also the case() must have one of those primitive data types. Using the System.out.println will help you to see what is happening in the within the computeCost() method so you can determine if the program is working as expected.

You will also need to correct you if statement. It must evaluate true or false. So you could have if(movieCode.length()>1)
7 years ago
Also look for local java users groups, that will give you the opportunity to network with other programmers who may be able to give advice and contacts. Try this link to locate a group.
7 years ago
Thank you Rob, when I remove the <Employee> from Staff and put ArrayList <Employee> the code works fine.
7 years ago
The following code is giving me compile errors on line 11, when I try to cast an Object to an Employee class. If I made a class without extending ArrayList, casting would not be a problem. I am not sure what the rules are that are causing the compile errors when I extend ArrayList.



Error
cannot find symbol
symbol : method getName()
location: class java.lang.Object
e.getName();// compile errors

7 years ago
Have you tried the Apache Examples? I found them to be very helpful, and learned to use the examples to adapt my requirements. If so, did you have a specific problem with the examples?
Thank you, I did find that on the JUnit.org site while I was searching for a solution. However, I keep getting compile errors

cannot find symbol
symbol : method assertArrayEquals(int[],int[])
location: class mvc.DateEntryFormatterunit4Test
assertArrayEquals(expResult, result);
1 error



I am using NetBeans 6.9, I have JUnit 4.5 in the library and the JDK 1.6 on a mac.

I am not sure now what the problem is??
7 years ago
I am testing a method that has a string input and returns an int[] (see code below)
The assert fails because the int[] expResult = {2010,1,23} is a different Object, if I manually test each int in the two arrays, I will see they are the same value.



My question is for JUnit testing do you have to override the assertEquals when comparing arrays?
7 years ago