Steffe Wilson

Ranch Hand
+ Follow
since Sep 30, 2015
Merit badge: grant badges
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steffe Wilson

Rob Camick wrote:

AWT which two specific areas of the screen have changed and need to be redrawn,

It does NOT redraw two specific areas of the screen.

It only redraws one larger area of the screen.

If you have the original square at (0, 0) and click at (100, 100), then it will redraw an Rectangle on (0, 0, 120, 120). So redraws a large rectangle, not the specific areas.

So if the areas are close to one another only a small area is painted. If the areas are far apart then a large area is repainted.

Rob, you are leaving out a key part of my statement and then saying my post is inaccurate!

This is what I said:

the two calls to repaint() that occur within moveSquare() tell AWT which two specific areas of the screen have changed and need to be redrawn

I worded my post carefully. I didn't say anything about how it was drawn by AWT, you had already covered that in detail and I was trying to clarify why repaint() was called twice which is the question that nick originally posted and nick's second post indicated he still didn't follow why the co-ordinates changed between the two calls so that is what I focused on in my post.

6 years ago

Rob Camick wrote:

tell AWT which two specific areas of the screen have changed and need to be redrawn, ie the area where the square was and the area where the square is.

No that is not accurate.

It does not track the specific areas that need to be withdrawn.

It tracks the smallest rectangular area that contains the two areas to be drawn and then repaints that area in one paint request.

Reread my answer and look at the calculation for this area to be redrawn.

Which part of my post is inaccurate and incompatible with yours?
6 years ago
The following describes how computer animation works in very broad terms. If I'm understanding your question correctly then this should help.
You don't see that loop in the oracle demo code because its managed inside AWT but the two calls to repaint() that occur within moveSquare() tell AWT which two specific areas of the screen have changed and need to be redrawn, ie the area where the square was and the area where the square is. The squareX, squareY variables save the new position of the object in preparation for the next time the background needs to be redrawn, ie the next time moveSquare() is called, which happens next time the mouse is dragged or clicked.
6 years ago
You can do it like this..

6 years ago

Kaplan Self test practice explain it as...

A default constructor can be overloaded in a subclass. If no constructor is defined for a
class, then the compiler will automatically provide the default constructor. Because a
subclass can define its own constructors without affecting the superclass, a constructor with
parameters can be defined that invokes the superclass constructor, implicitly or explicitly.
The constructor must not use a different name. In the same class, an overloaded constructor
uses the same name. Because subclasses differ in name from their superclass, an
overloaded constructor will have a different name.

So they are saying you can overload the default constructor of a base class, say A, with an explicit constructor in a subclass, say B.

Any constructors in class A will have the name A and any constructors in class B will have the name B (which they acknowledge). But by definition an overloaded method or constructor must have the same name, so this cannot be an overload.
You haven't allocated any memory for your data structures such as g, p or p_Node. Lookup malloc().
6 years ago
Haven't checked all the logic but line 29 needs to be a strcpy() doesn't it?

6 years ago
Also, you don't need to check that hoursCompleted are greater than a value you have previously dealt with because by that point you have entered an else state.


6 years ago

Christian Pflugradt wrote: As far as casting is concerned the compiler will detect an attempt to cast to a completely unrelated object (like casting a Date to a String) but it won't detect incorrect downcasts.
I don't know the exact specifications, so if someone could point us to official documentation regarding which casting errors the compiler can detect I'd be grateful.

The source and target of the class cast must be related for the compiler to accept the cast - that means that they must be in the same vertical class hierarchy.
Source ISA Dest or Dest ISA Source

The spec is here, see the first bullet point of 5.5.1:

In OP's case:
Animal ISA Dog fails the compiler casting check.. but Dog ISA Animal succeeds so the cast is accepted by the compiler.

6 years ago
Interesting thread. I tried a few things myself. First I moved class Z to its own named package and moved the three method calls into an instance method of Z.

This didn't make any difference; javac still allowed it all to compile and the JVM threw IllegalAccessError on the third call.

If I removed the "extends B" clause from Z then javac correctly flagged that the three methods were not visible for Z to call.

Then I tried removing the definition of someStaticMethod() from class C and, as expected, the call to C.someStaticMethod() from Z succeeded because java invokes the class B definition of the method (because class C extends B, the B version of the method is accessible to Z and it is no longer hidden).

I then moved from command line over to eclipse and, as others have said, under eclipse the same code generated a warning as soon as I typed in the offending line (it reported someStaticMethod() in C was not visible for the call). This puzzled me and I wondered if more warnings were enabled when eclipse invoked javac, but not so: what I hadn't previously appreciated is that eclipse has its own built-in compiler (ECJ) which is completely independent of javac.

So after all that, and a lot of head scratching, I have come to the same conclusion as Dave Tolls in an earlier post, that it seems likely that the observed behaviour is a consequence of a javac compiler deficiency.
6 years ago
I use the Recent Topics page as my bookmarked 'landing page'. Only problem is, it lists recent topics from all the forums, which means that:
(1) I have to visually filter out all the stuff I am not interested in, and
(2) stuff that I would be interested in gets bumped off the front page by the items I don't need to see.

It is already possible under each user's Site Preferences to configure forums to be excluded from the Home Page display - could this list also be applied to the Recent Topics page?
6 years ago
Object creation isn't a "big bang" whereby a fully formed object suddenly appears out of nothing, instead there are discrete steps involved in the process.
A bare-bones object is created first when memory is allocated to it (which means that this has a value) and then various actions take place to fully form the object including the steps quoted above for setting up instance variables, running constructors, etc.
6 years ago

Fred Kleinschmidt wrote:The 'this' keyword should never be used this way when initializing instance variables. [...]
The problem is that the instance is not fully complete before the constructor finishes, so may try to reference things that are not yet initialized.

Perhaps worthy of a further clarification...

The JLS says (section 8.6):

Instance initializers are permitted to refer to the current object via the keyword this (§15.8.3), to use the keyword super (§15.11.2, §15.12), and to use any type variables in scope.

but continues:

Use of instance variables whose declarations appear textually after the use is sometimes restricted, even though these instance variables are in scope.

So its the forward reference that is the cause of the problem here, rather than the use of this per se. If you swap over the declarations of str and str2 it would work as expected. But I take your point.

6 years ago