Search Results

Search found 29191 results on 1168 pages for 'joel in go'.

Page 19/1168 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • beginning oop php question: do constructors take the place of getter?

    - by Joel
    I'm working through this tutorial: http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php At first he has you create a setter and getter method in the class: <?php class person{ var $name; function set_name($new_name){ $this->name=$new_name; } function get_name(){ return $this->name; } } php?> And then you create the object and echo the results: <?php $stefan = new person(); $jimmy = new person(); $stefan ->set_name("Stefan Mischook"); $jimmy ->set_name("Nick Waddles"); echo "The first Object name is: ".$stefan->get_name(); echo "The second Object name is: ".$jimmy->get_name(); ?> Works as expected, and I understand. Then he introduces constructors: class person{ var $name; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name){ $this->name=$new_name; } function get_name(){ return $this->name; } } And returns like so: <?php $joel = new person("Joel"); echo "The third Object name is: ".$joel->get_name(); ?> This is all fine and makes sense. Then I tried to combine the two and got an error, so I'm curious-is a constructor always taking the place of a "get" function? If you have a constructor, do you always need to include an argument when creating an object? Gives errors: <?php $stefan = new person(); $jimmy = new person(); $joel = new person("Joel Laviolette"); $stefan ->set_name("Stefan Mischook"); $jimmy ->set_name("Nick Waddles"); echo "The first Object name is: ".$stefan->get_name(); echo "The second Object name is: ".$jimmy->get_name(); echo "The third Object name is: ".$joel->get_name(); ?>

    Read the article

  • Can someone clarify what this Joel On Software quote means?

    - by Bob
    I was reading Joel On Software today and ran across this quote: Without understanding functional programming, you can't invent MapReduce, the algorithm that makes Google so massively scalable. The terms Map and Reduce come from Lisp and functional programming. MapReduce is, in retrospect, obvious to anyone who remembers from their 6.001-equivalent programming class that purely functional programs have no side effects and are thus trivially parallelizable. What does he mean when he says functional programs have no side effects? And how does this make parallelizing trivial?

    Read the article

  • Stopping the animation after you let go of a key

    - by Michael Zeuner
    What I have right now is an animation that starts when I press space: if(input.isKeyDown(Input.KEY_SPACE)) player = movingRightSwingingSword; However when I stop clicking space my animation continues. until I move my player, how do I make it so it stops the animation right when you let go of space? A few lines Animation player, movingUp, movingDown, movingLeft, movingRight, movingRightSwingingSword; int[] duration = {200,200}; public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { Image[] attackRight = {new Image("res/buckysRightSword1.png"), new Image("res/buckysRightSword2.png")}; movingRightSwingingSword = new Animation(attackRight, duration, true); } public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { if(input.isKeyDown(Input.KEY_SPACE)) player = movingRightSwingingSword; } Full Code package javagame; import org.newdawn.slick.*; import org.newdawn.slick.state.*; public class Play extends BasicGameState { Animation player, movingUp, movingDown, movingLeft, movingRight, movingRightSwingingSword; Image worldMap; boolean quit = false; int[] duration = {200,200}; float playerPositionX = 0; float playerPositionY = 0; float shiftX = playerPositionX + 320; float shiftY = playerPositionY + 160; public Play(int state) { } public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { worldMap = new Image("res/world.png"); Image[] walkUp = {new Image("res/buckysBack.png"), new Image("res/buckysBack.png")}; Image[] walkDown = {new Image("res/buckysFront.png"), new Image("res/buckysFront.png")}; Image[] walkLeft = {new Image("res/buckysLeft.png"), new Image("res/buckysLeft.png")}; Image[] walkRight = {new Image("res/buckysRight.png"), new Image("res/buckysRight.png")}; Image[] attackRight = {new Image("res/buckysRightSword1.png"), new Image("res/buckysRightSword2.png")}; movingUp = new Animation(walkUp, duration, false); movingDown = new Animation(walkDown, duration, false); movingLeft = new Animation(walkLeft, duration, false); movingRight = new Animation(walkRight, duration, false); //doesnt work! vvv movingRightSwingingSword = new Animation(attackRight, duration, true); player = movingDown; } public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException { worldMap.draw(playerPositionX, playerPositionY); player.draw(shiftX, shiftY); g.drawString("Player X: " + playerPositionX + "\nPlayer Y: " + playerPositionY, 400, 20); if (quit == true) { g.drawString("Resume (R)", 250, 100); g.drawString("MainMenu (M)", 250, 150); g.drawString("Quit Game (Q)", 250, 200); if (quit==false) { g.clear(); } } } public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { Input input = gc.getInput(); if(input.isKeyDown(Input.KEY_UP)) { player = movingUp; playerPositionY += delta * .1f; if(playerPositionY>162) playerPositionY -= delta * .1f; } if(input.isKeyDown(Input.KEY_DOWN)) { player = movingDown; playerPositionY -= delta * .1f; if(playerPositionY<-600) playerPositionY += delta * .1f; } if(input.isKeyDown(Input.KEY_RIGHT)) { player = movingRight; playerPositionX -= delta * .1f; if(playerPositionX<-840) playerPositionX += delta * .1f; } if(input.isKeyDown(Input.KEY_LEFT)) { player = movingLeft; playerPositionX += delta * .1f; if(playerPositionX>318) playerPositionX -= delta * .1f; } if(input.isKeyDown(Input.KEY_SPACE)) player = movingRightSwingingSword; if(input.isKeyDown(Input.KEY_ESCAPE)) quit = true; if(input.isKeyDown(Input.KEY_R)) if (quit == true) quit = false; if(input.isKeyDown(Input.KEY_M)) if (quit == true) {sbg.enterState(0); quit = false;} if(input.isKeyDown(Input.KEY_Q)) if (quit == true) System.exit(0); } public int getID() { return 1; } }

    Read the article

  • Photo inside the image view should not go cross on dragging

    - by TGMCians
    I want photo inside the imageview should not go outside on dragging. In my code when i start to drag bitmap inside the imageview its goes out from imageview but i want when it cross the imageview its should come at starting point of imageview. How to achieve this. please help me for this. @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.save(); scaleCount=scaleCount+scale; angleCount = addAngle(angleCount, Math.toDegrees(angle)); Log.v("Positions", "X: "+x+" " + "Y: "+y); Log.d("ScaleCount", String.valueOf(scaleCount)); Log.d("Angle", String.valueOf(angleCount)); if (!isInitialized) { int w = getWidth(); int h = getHeight(); position.set(w / 2, h / 2); isInitialized = true; } Paint paint = new Paint(); Log.v("Height and Width", "Height: "+ getHeight() + "Width: "+ getWidth()); transform.reset(); transform.postTranslate(-width / 2.0f, -height / 2.0f); transform.postRotate((float) Math.toDegrees(angle)); transform.postScale(scale, scale); transform.postTranslate(position.getX(), position.getY()); canvas.drawBitmap(bitmap, transform, paint); canvas.restore(); BitmapWidth=BitmapWidth+bitmap.getScaledWidth(canvas); BitmapHeight=BitmapHeight+bitmap.getScaledHeight(canvas); try { /*paint.setColor(0xFF007F00); canvas.drawCircle(vca.getX(), vca.getY(), 30, paint); paint.setColor(0xFF7F0000); canvas.drawCircle(vcb.getX(), vcb.getY(), 30, paint);*/ /*paint.setColor(0xFFFF0000); canvas.drawLine(vpa.getX(), vpa.getY(), vpb.getX(), vpb.getY(), paint); paint.setColor(0xFF00FF00); canvas.drawLine(vca.getX(), vca.getY(), vcb.getX(), vcb.getY(), paint);*/ } catch(NullPointerException e) { // Just being lazy here... } } @Override public boolean onTouch(View v, MotionEvent event) { vca = null; vcb = null; vpa = null; vpb = null; x=event.getX(); y=event.getY(); try { touchManager.update(event); if (touchManager.getPressCount() == 1) { vca = touchManager.getPoint(0); vpa = touchManager.getPreviousPoint(0); position.add(touchManager.moveDelta(0)); } else { if (touchManager.getPressCount() == 2) { vca = touchManager.getPoint(0); vpa = touchManager.getPreviousPoint(0); vcb = touchManager.getPoint(1); vpb = touchManager.getPreviousPoint(1); VMVector2D current = touchManager.getVector(0, 1); VMVector2D previous = touchManager.getPreviousVector(0, 1); float currentDistance = current.getLength(); float previousDistance = previous.getLength(); if (currentDistance-previousDistance != 0) { scale *= currentDistance / previousDistance; } angle -= VMVector2D.getSignedAngleBetween(current, previous); /*angleCount=angleCount+angle;*/ } } invalidate(); } catch(Exception exception) { // Log.d("VM", exception.getMessage()); } return true; }

    Read the article

  • Embedded pdf object steals focus and will not let it go

    - by Kristian Hebert
    Hi guys, I was given the task of adding some usability to one of our applications, ie. make sure that every controll has a shortcut key, and that they can be reached by "tabbing" through the page. The gui runs in a IE. control on a winform, and consists of asp.net pages, so basically it is just asp.net always running in internet explorer. My problem is that one of the pages has an embeded pdf in it, like so: <object tabindex="-1" height="273" width="663" visible="false" type="Application/pdf" data="showpdf.ashx#navpanes=0"></object> showpdf.ashx is an httphandler, that streams the pdf contents to the response. It does not handle focus in any way. Now when I run this page, the pdf application steals focus, no matter what I do to set it to another control. And when it takes focus, I cannot take it back with the keyboard. Only a mouseclick on the page will set it to another control. I have tried to set focus in code behind OnPreRender, or in jevescript, but no luck. It seems that the http handler always runs after all the other code, and it sets focus on the pdf object. Any thought would be greatly appreciated.

    Read the article

  • PLSQL: How to go about it

    - by Rachel
    I searched for this topic on SO but I did not found any recommendations and so am asking it as I am new to PLSQL and want to understand it: What is best way to get started with PLSQL ? What are best online resources or books available out there for understand PLSQL which you would recommend ? Do we have any comprehensive online video tutorial for PLSQL ? More Importantly: What Concepts should I be clear with to say myself as an PLSQL Developer?

    Read the article

  • Do MSDTC and disaster recovery go together?

    - by DevDelivery
    Our application writes to multiple Sql Server databases within a distributed transaction. The Ops guys are saying that this messes up their disaster recovery plan because while the transactions on the live tables may commit at the same time, the log shipping on the separate databases happen at slightly different times. So in in a disaster recovery situation, there will be a few partial transactions. Is there a method for maintaining separate but synced databases in DR? Or do we have to re-design to relatively independent databases (or a single database)?

    Read the article

  • Where did my Toolbar button go?

    - by Driss Zouak
    When MyView gets pushed on to the NavigationController, I have the following code public override void ViewDidLoad () { this.NavigationController.Toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem("Next",UIBarButtonItemStyle.Plain, ClickNext) }, true); this.NavigationItem.Title = "Proposal Plan - Step 1"; } The Title gets set properly, and the code runs but in my Toolbar at the bottom of the view I don't have the "Next" button I am expecting. I put a breakpoint and verified that the Toolbar after running that line does have my button, but still nothing. What am I mising?

    Read the article

  • Problems with sticky footer - CSS - main content wont go 100% height (float)

    - by Jamie
    I'm trying to implement hxxp://www.cssstickyfooter.com however I am having a few problems! See screenshot: hxxp://img22.imageshack.us/img22/2654/71161106.jpg The div "Content" contains both left and right columns. On smaller resolutions this is working as expected however once the user starts to increase there resolution the content doesn't expand as I intend it to. If you notice the blue box. That should stretch to the footer at the bottom of the page. If you notice that the blue divider line (right_container3-4) stops also at the same point. CODE HTML: hxxp://tinyurl.com/m39x52 CSS: hxxp://tinyurl.com/lb62ej I would apriciate any help at all! I've been racking my brains for ages on this one, its just a small site so I suppose it's not too much of an issue. But it's nice to know all the same! Thankyou P.S. Sorry about the URL formatting

    Read the article

  • Where should 'CreateMap' statements go?

    - by jonathanconway
    I frequently use AutoMapper to map Model (Domain) objects to ViewModel objects, which are then consumed by my Views, in a Model/View/View-Model pattern. This involves many 'Mapper.CreateMap' statements, which all must be executed, but must only be executed once in the lifecycle of the application. Technically, then, I should keep them all in a static method somewhere, which gets called from my Application_Start() method (this is an ASP.NET MVC application). However, it seems wrong to group a lot of different mapping concerns together in one central location. Especially when mapping code gets complex and involves formatting and other logic. Is there a better way to organize the mapping code so that it's kept close to the ViewModel that it concerns? (I came up with one idea - having a 'CreateMappings' method on each ViewModel, and in the BaseViewModel, calling this method on instantiation. However, since the method should only be called once in the application lifecycle, it needs some additional logic to cache a list of ViewModel types for which the CreateMappings method has been called, and then only call it when necessary, for ViewModels that aren't in that list.)

    Read the article

  • Where did System.Design go?

    - by Nilbert
    I am making a C# project in which I am using ScintillaNet, and it says: The referenced assembly "ScintillaNet" could not be resolved because it has a dependency on "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. I tried adding a reference to System.Design, but it doesn't exist in my list. Do I need to download it somewhere? I have MS Visual Studio 10.

    Read the article

  • Changing text of TextView -- old text doesn't go away (Android 4.1.2)

    - by Jason Costabile
    I'm pretty new to Android development. Trying to accomplish something fairly simple -- change some displayed text when a timer ticks. Here's the potentially relevant code: CountDownTimer currentTimer; Resources res; TextView timerText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_exercise); res = getResources(); timerText = (TextView) findViewById(R.id.timer_text); } @Override protected void onStart() { super.onStart(); //"Get ready" countdown currentTimer = new CountDownTimer(5000, 1000) { @Override public void onTick(long millisUntilFinished) { timerText.setText("" + (int)Math.ceil(millisUntilFinished / 1000.0)); } @Override public void onFinish() { ... } }; currentTimer.start(); } This works fine on an emulated 4.2.2 device, but on a 4.1.2 device (both physical and emulated), the changed TextView appears as such while the countdown proceeds: If you can't tell, that's the numbers 5,4,3 overlayed. So, when I set a new string for the TextView, the new string is displayed but without replacing the old string. Any other TextViews used in my app behave in the same way. Any ideas what the problem is and how to fix it? Edit: From the XML layout file: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".ExerciseActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:keepScreenOn="true" android:orientation="vertical" > ... <TextView android:id="@+id/timer_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:textIsSelectable="false" android:hint="@string/timer_default" /> ... </LinearLayout> That's all that could be relevant.

    Read the article

  • How would you go about tackling this problem?

    - by incrediman
    I have a programming contest coming up in about half a week, and I've been prepping :) I found a bunch of questions from this canadian competition, they're great practice: http://cemc.math.uwaterloo.ca/contests/computing/2009/stage2/day1.pdf I'm looking at problem B ("Dinner"). Any idea where to start? I can't really think of anything besides the naive approach (ie. trying all permutations) which would take too long to be a valid answer. Btw, the language there says c++ and pascal I think, but i don't care what language you use - I mean really all I want is a brief description of how to tackle the problem. Like "use X technique treating each programmer as a Y" or something :)

    Read the article

  • Where to go after PHP?

    - by sub
    I'm starting to get sick of PHP and search for a web-development language with future. What to learn next? Can I rely on the availability of Ruby (on Rails) on my client's hosters? Could Django be a better choice?

    Read the article

  • Annoying Blank pop-up window go away

    - by No Soup for YOU
    Hi All, Sorry about the wording for my question title. I have a basic HTML anchor tag that when clicked it is suppose to bring up a dialog box to download a file from a differnt website. I am using an attribute of target="_blank" so that when my hyperlink is clicked, I don't navigate away from my main window. This is all the easy part (if it was so easy I wouldnt be here though). When I do the above though, and click on the hyperlink, an annoying blank window pops up with my download dialog box behind it. How do I get rid of that annoying blank window and keep only my download dialog box on the screen? Below is the HTML I'm working with... <a href="http://www.fake-domain-name.com/downloads/setup.msi" target="_blank"> <img src="images/download.png" alt="download file"/> </a>

    Read the article

  • 301 Redirects, and the correct regex to go with it

    - by Tisch
    Hi Guys, I have several URLs that I want to redirect to the same place, however these are dynamic URLs. The structure is something like this: http://www.mysite.com/declaration/list?[query_string] What I think would be ideal for this situation is to use some regex in my .htaccess file to redirect all these links to the sites home page. I was wondering if someone could help me with the regex for this situation. So far, I have this, but it doesn't work: RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^/declaration/list$ http://www.mysite.com/$ [R=301,L] My regex is weak to say the least, something I want to, and am trying to learn. Thanks in advance. Tom

    Read the article

  • C String literals: Where do they go?

    - by Chris Cooper
    I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory. I am interested in where the string DOES get allocated/stored, etc. I did find one intriguing answer here, saying: Defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smart trick, don't bother). but, it had to do with C++, not to mention that it says not to bother. I am bothering. =D So my question is, again, where and how is my string literal kept? Why should I not try to alter it? Does the implementation vary by platform? Does anyone care to elaborate on the "smart trick?" Thanks for any explanations.

    Read the article

  • why egrep's stdout did not go through pipe?

    - by ccfenix
    Hi, i got a weird problem regarding egrep and pipe I tried to filter a stream containing some lines who start with a topic name, such as "TICK:this is a tick message\n" When I try to use egrep to filter it : ./stream_generator | egrep 'TICK' | ./topic_processor It seems that the topic_processor never receives any messages However, when i use the following python script: ./stream_generator | python filter.py --topics TICK | ./topic_processor everything looks to be fine. I guess there need to be a 'flush' mechanism for egrep as well, is this correct? Can anyone here give me a clue? Thanks a million import sys from optparse import OptionParser if __name__ == '__main__': parser = OptionParser() parser.add_option("-m", "--topics", action="store", type="string", dest="topics") (opts, args) = parser.parse_args() topics = opts.topics.split(':') while True: s = sys.stdin.readline() for each in topics: if s[0:4] == each: sys.stdout.write(s) sys.stdout.flush()

    Read the article

  • How would I go about prevent DLL injection.

    - by wowus
    So the other day, I saw this: http://www.edgeofnowhere.cc/viewtopic.php?p=2483118 and it goes over three different methods of DLL injection. How would I prevent these from the process? Or at a bare minimum, how do I prevent the first one? I was thinking maybe a Ring 0 driver might be the only way to stop all three, but I'd like to see what the community thinks.

    Read the article

  • Pythonic / itertools way to go through a dict?

    - by dmd
    def reportCSV(t): ret = '' for ev in t: for p in t[ev]: for w in t[ev][p]: ret += ','.join((ev, p, w, t[ev][p][w])) + '\n' return ret What is a more pythonic way to do this, e.g. using itertools or the like? In this case I'm just writing it out to a CSV file. t is a dict t[ev] is a dict t[ev][p] is a dict t[ev][p][w] is a float I'm not sure how I'd use itertools.product in this case.

    Read the article

  • jQuery - Add click event to Div and go to first link found

    - by LuckyShot
    Hi guys, I think I've been too much time looking at this function and just got stuck trying to figure out the nice clean way to do it. It's a jQuery function that adds a click event to any div with a click CSS class found in the page and when clicked it redirects the user to the first link found in the div. function clickabledivs() { $('.click').each( function (intIndex) { $(this).bind("click", function(){ window.location = $( "#"+$(this).attr('id')+" a:first-child" ).attr('href'); }); } ); } The code simply works although I'm pretty sure there is a fairly better way to accomplish it, specially the selector I am using: $( "#"+$(this).attr('id')+" a:first-child" ) looks too long and slow. Any ideas? Please let me know if you need more details. Thanks! PS: I've got some jQuery benchmarking reference from Project2k.de here: http://blog.projekt2k.de/2010/01/benchmarking-jquery-1-4/

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >