Search Results

Search found 1020 results on 41 pages for 'car'.

Page 9/41 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • What's the best way to move cars along roads

    - by David Thielen
    I am implementing car movement game (sort-of like Locomotion). So 60 times a second I have to advance the movement of each car. The problem is I have to look ahead to see if there is a slower car, stop sign, or red light ahead. And then slow down appropiately. I also want to have the cars take time to go from stopped to full speed and again to slow down. I'm not implementing full-blown physics, but just a tick by tick speed up/slow down as that provides most of the realism to match what people expect to see. The best I've come up with is to walk out the full distance the car would travel of it was slowing to a stop and see if anywhere along that path it needed to slow down or stop. And then move it forward appropiately. I am moving the cars 60 times a second so I need this to be fast. And walking out that whole path each tick strikes me as processor intensive. What's the best way to do this?

    Read the article

  • How to handle sorting of complex objects?

    - by AedonEtLIRA
    How would one sort a list of objects that have more than one sortable element? Suppose you have a simple object Car and car is a defined as such: class Car { public String make; public String model; public int year; public String color; // ... No methods, just a structure / container } I designed a simple framework that would allow for multiple SortOptions to be provided to a Sorter that would then sort the list. interface ISorter<T> { List<T> sort(List<T> items); void addSortOption(ISortOption<T> option); ISortOption<T>[] getSortOptions(); void setSortOption(ISortOption<T> option); } interface ISortOption<T> { String getLabel(); int compare(T t1, T t2); } Example use class SimpleStringSorter extends MergeSorter<String> { { addSorter(new AlphaSorter()); } private static final class AlphaSorter implements ISortOption<String> { // ... implementation of alpha compare and get label } } The issue with this solution is that it is not easily expandable. If car was to ever receive a new field, say, currentOwner. I would need to add the field, then track down the sorter class file, implement a new sort option class then recompile the application for redistribution. Is there an easier more expandable/practical way to sort data like this?

    Read the article

  • I am looking to make a spaceship tilt as it corners but I cant get it to return

    - by bobthemac
    I am using the TL game engine I am not allowed to use a physics engine but I need to make the spaceship lean as it corners, I can make it lean but cannot make it return to its starting position. I have looked at implementing some kind of spring physics but I don't understand it. Here is my code so far if(myEngine->KeyHeld(Key_A)) { car->RotateY(carSteer * frameTime); if(carSteer >= -carMaxSteer) { carSteer -= carSteerIncrement; car->RotateLocalZ(-(carSteer * frameTime)); } } if(!myEngine->KeyHeld(Key_A)) { if(carSteer < 0) { carSteer = 0; } } if(myEngine->KeyHeld(Key_D)) { car->RotateY(carSteer * frameTime); if(carSteer <= carMaxSteer) { carSteer += carSteerIncrement; car->RotateLocalZ(-(carSteer * frameTime)); } } if(!myEngine->KeyHeld(Key_D)) { if(carSteer > 0) { carSteer = 0; } } All the functions I am calling are built into the engine and I did not write them. Any Help Would Be Appreciated Thanks.

    Read the article

  • Tail-recursive implementation of take-while

    - by Giorgio
    I am trying to write a tail-recursive implementation of the function take-while in Scheme (but this exercise can be done in another language as well). My first attempt was (define (take-while p xs) (if (or (null? xs) (not (p (car xs)))) '() (cons (car xs) (take-while p (cdr xs))))) which works correctly but is not tail-recursive. My next attempt was (define (take-while-tr p xs) (let loop ((acc '()) (ys xs)) (if (or (null? ys) (not (p (car ys)))) (reverse acc) (loop (cons (car ys) acc) (cdr ys))))) which is tail recursive but needs a call to reverse as a last step in order to return the result list in the proper order. I cannot come up with a solution that is tail-recursive, does not use reverse, only uses lists as data structure (using a functional data structure like a Haskell's sequence which allows to append elements is not an option), has complexity linear in the size of the prefix, or at least does not have quadratic complexity (thanks to delnan for pointing this out). Is there an alternative solution satisfying all the properties above? My intuition tells me that it is impossible to accumulate the prefix of a list in a tail-recursive fashion while maintaining the original order between the elements (i.e. without the need of using reverse to adjust the result) but I am not able to prove this. Note The solution using reverse satisfies conditions 1, 3, 4.

    Read the article

  • Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think?

    - by Prog
    I understand the concept of an object, and as a Java programmer I feel the OO paradigm comes rather naturally to me in practice. However recently I found myself thinking: Wait a second, what are actually the practical benefits of using an object over using a static class (with proper encapsulation and OO practices)? I could think of two benefits of using an object (both significant and powerful): Polymorphism: allows you to swap functionality dynamically and flexibly during runtime. Also allows to add new functionality 'parts' and alternatives to the system easily. For example if there's a Car class designed to work with Engine objects, and you want to add a new Engine to the system that the Car can use, you can create a new Engine subclass and simply pass an object of this class into the Car object, without having to change anything about Car. And you can decide to do so during runtime. Being able to 'pass functionality around': you can pass an object around the system dynamically. But are there any more advantages to objects over static classes? Often when I add new 'parts' to a system, I do so by creating a new class and instantiating objects from it. But recently when I stopped and thought about it, I realized that a static class would do just the same as an object, in a lot of the places where I normally use an object. For example, I'm working on adding a save/load-file mechanism to my app. With an object, the calling line of code will look like this: Thing thing = fileLoader.load(file); With a static class, it would look like this: Thing thing = FileLoader.load(file); What's the difference? Fairly often I just can't think of a reason to instantiate an object when a plain-old static-class would act just the same. But in OO systems, static classes are fairly rare. So I must be missing something. Are there any more advantages to objects other from the two that I listed? Please explain.

    Read the article

  • Should we rename overloaded methods?

    - by Mik378
    Assume an interface containing these methods : Car find(long id); List<Car> find(String model); Is it better to rename them like this? Car findById(long id); List findByModel(String model); Indeed, any developer who use this API won't need to look at the interface for knowing possible arguments of initial find() methods. So my question is more general : What is the benefit of using overloaded methods in code since it reduce readability?

    Read the article

  • How do I detect multiple sprite collisions when there are >10 sprites?

    - by yao jiang
    I making a small program to animate the astar algorithm. If you look at the image, there are lots of yellow cars moving around. Those can collide at any moment, could be just one or all of them could just stupidly crash into each other. How do I detect all of those collisions? How do I find out which specific car has crash into which other car? I understand that pygame has collision function, but it only detects one collision at a time and I'd have to specify which sprites. Right now I am just trying to iterate through each sprite to see if there is collision: for car1 in carlist: for car2 in carlist: collide(car1, car2); This can't be the proper way to do it, if the car list goes to a huge number, a double loop will be too slow.

    Read the article

  • If Apple made Cars [closed]

    - by benhowdle89
    There was a joke going round a few months(?) ago that if the GM industry kept up with the computer industry that we'd all be better off (in relation to driving and costs). There was also a counter joke that if Microsoft made Cars you would, for example, have to squeeze the wing mirror, honk the horn and move the gearstick the reboot the car (CTRL + ALT + DEL) This got me thinking in terms of Apple's recent iPad 2 release, if Apple made cars what would they be like? What sort of technological advancements would software developers and programmers be able to implement if you built a car in a similar fashion to building an iPhone app. Xcode is you Mechanics garage, as it were. What would a car look like if it was designed by Apple Chief of Design: Jonothan Ive?

    Read the article

  • What Can We Learn About Software Security by Going to the Gym

    - by Nick Harrison
    There was a recent rash of car break-ins at the gym. Not an epidemic by any stretch, probably 4 or 5, but still... My gym used to allow you to hang your keys from a peg board at the front desk. This way you could come to the gym dressed to work out, lock your valuables in your car, and not have anything to worry about. Ignorance is bliss. The problem was that anyone who wanted to could go pick up your car keys, click the unlock button and find your car. Once there, they could rummage through your stuff and then walk back in and finish their workout as if nothing had happened. The people doing this were a little smatter then the average thief and would swipe some but not all of your cash leaving everything else in place. Most thieves would steal the whole car and be busted more quickly. The victims were unaware that anything had happened for several days. Fortunately, once the victims realized what had happened, the gym was still able to pull security tapes and find out who was misbehaving. All of the bad guys were busted, and everyone can now breathe a sigh of relieve. It is once again safe to go to the gym. Except there was still a fundamental problem. Putting your keys on a peg board by the front door is just asking for bad things to happen. One person got busted exploiting this security flaw. Others can still be exploiting it. In fact, others may well have been exploiting it and simply never got caught. How long would it take you to realize that $10 was missing from your wallet, if everything else was there? How would you even know when it went missing? Would you go to the front desk and even bother to ask them to review security tapes if you were only missing a small amount. Once highlighted, it is easy to see how commonly such vulnerability may have been exploited. So the gym did the very reasonable precaution of removing the peg board. To me the most shocking part of this story is the resulting uproar from gym members losing the convenient key peg. How dare they remove the trusted peg board? How can I work out now, I have to carry my keys from machine to machine? How can I enjoy my workout with this added inconvenience? This all happened a couple of weeks ago, and some people are still complaining. In light of the recent high profile hacking, there are a couple of parallels that can be drawn. Many web sites are riddled with vulnerabilities are crazy and easily exploitable as leaving your car keys by the front door while you work out. No one ever considered thanking the people who were swiping these keys for pointing out the vulnerability. Without a hesitation, they had their gym memberships revoked and are awaiting prosecution. The gym did recognize the vulnerability for what it is, and closed up that attack vector. What can we learn from this? Monitoring and logging will not prevent a crime but they will allow us to identify that a crime took place and may help track down who did it. Once we find a security weakness, we need to eliminate it. We may never identify and eliminate all security weaknesses, but we cannot allow well known vulnerabilities to persist in our system. In our case, we are not likely to meet resistance from end users. We are more likely to meet resistance from stake holders, product owners, keeper of schedules and budgets. We may meet resistance from integration partners, co workers, and third party vendors. Regardless of the source, we will see resistance, but the weakness needs to be dealt with. There is no need to glorify a cracker for bringing to light a security weakness. Regardless of their claimed motives, they are not heroes. There is also no point in wasting time defending weaknesses once they are identified. Deal with the weakness and move on. In may be embarrassing to find security weaknesses in our systems, but it is even more embarrassing to continue ignoring them. Even if it is unpopular, we need to seek out security weaknesses and eliminate them when we find them. http://www.sans.org has put together the Common Weakness Enumeration http://cwe.mitre.org/ which lists out common weaknesses. The site navigation takes a little getting used to, but there is a treasure trove here. Here is the detail page for SQL Injection. It clearly states how this can be exploited, in case anyone doubts that the weakness should be taken seriously, and more importantly how to mitigate the risk.

    Read the article

  • Form Validation, Dependant Drop Downs, Data Level Security in OWS for DotNetNuke - 5 Videos

    In this tutorial we demonstrate some very advanced techniques for building a car parts application in Open Web Studio. Throughout the tutorial we cover form input, validation, how to use dependant drop down lists, populating checkbox lists and introduce a new concept of data level security. Data level security allows you to control which data a user can access within a module. The videos contain: Video 1 - How to Setup Form Validation Video 2 - Car Parts Application, Assigning Security Roles into a Global Session Variable Video 3 - How to Build the Categories Module with Data Level Security Video 4 - How to Build the SubCategories Module and Use SubQuery Video 5 - How to Build the Car Parts List Module Total Time Length: 44min 19secsDid you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Number of iterations to real time

    - by Ivansek
    I have an animation of traffic. I have 20 cars in road network, each car have a starting node and end node. Each car know how much distance does it need to travel in order to reach the end node. I move cars each 20 ms for 10 px. To move all cars from their start node to end node I need 60 iterations. That is 60*20ms = 1200ms. Now I want to convert this time, or use data that I have, to a real time where car move 50km/h. How can I do that? Any idea?

    Read the article

  • ASP.NET MVC model binding foreign key relationship

    - by Rory Fitzpatrick
    Is it possible to bind a foreign key relationship on my model to a form input? Say I have a one-to-many relationship between Car and Manufacturer. I want to have a form for updating Car that includes a select input for setting Manufacturer. I was hoping to be able to do this using the built-in model binding, but I'm starting to think I'll have to do it myself. My action method signature looks like this: public JsonResult Save(int id, [Bind(Include="Name, Description, Manufacturer")]Car car) The form posts the values Name, Description and Manufacturer, where Manufacturer is a primary key of type int. Name and Description get set properly, but not Manufacturer, which makes sense since the model binder has no idea what the PK field is. Does that mean I would have to write a custom IModelBinder that it aware of this? I'm not sure how that would work since my data access repositories are loaded through an IoC container on each Controller constructor.

    Read the article

  • How to fix type names conflicts in Dynamic Data

    - by SDReyes
    Hi Guys! We're working in a Dynamic Data project that will handle entities coming from two different namespaces: myModel.Abby and myModel.Ben. whose classes are: Abby myModel.Abby.Car myModel.Abby.Lollipop Ben myModel.Ben.Car myModel.Ben.Apple So myModel.Abby.Car and myModel.Ben.Car are homonym. when I try to register both ObjectContext's, an exception is thrown telling us that there are type name conflicts between the mentioned classes (although the types belong to different namespaces). How can we overcome type-name conflicts, caused by repeated type names among different namespaces?

    Read the article

  • NHibernate: Many-to-many relationship with field in the relationship table

    - by Fossmo
    I'm scratching my head; I have a Car table and a Customer table that have a many-to-many relationship. In this relationship table I want to add a column that can tell me what kind of relationship this is; is the customer testdriving the car, do he want to buy the car, ect. What I want to end up with is a class Car object that holds a collection of Customers and the relationship information. I might be looking at this the wrong way so feel free to push me in the right direction.

    Read the article

  • SQL Query for generating matrix like output querying related table in SQL Server

    - by Nagesh
    I have three tables: Product ProductID ProductName 1 Cycle 2 Scooter 3 Car Customer CustomerID CustomerName 101 Ronald 102 Michelle 103 Armstrong 104 Schmidt 105 Peterson Transactions TID ProductID CustomerID TranDate Amount 10001 1 101 01-Jan-11 25000.00 10002 2 101 02-Jan-11 98547.52 10003 1 102 03-Feb-11 15000.00 10004 3 102 07-Jan-11 36571.85 10005 2 105 09-Feb-11 82658.23 10006 2 104 10-Feb-11 54000.25 10007 3 103 20-Feb-11 80115.50 10008 3 104 22-Feb-11 45000.65 I have written a query to group the transactions like this: SELECT P.ProductName AS Product, C.CustName AS Customer, SUM(T.Amount) AS Amount FROM Transactions AS T INNER JOIN Product AS P ON T.ProductID = P.ProductID INNER JOIN Customer AS C ON T.CustomerID = C.CustomerID WHERE T.TranDate BETWEEN '2011-01-01' AND '2011-03-31' GROUP BY P.ProductName, C.CustName ORDER BY P.ProductName which gives the result like this: Product Customer Amount Car Armstrong 80115.50 Car Michelle 36571.85 Car Schmidt 45000.65 Cycle Michelle 15000.00 Cycle Ronald 25000.00 Scooter Peterson 82658.23 Scooter Ronald 98547.52 Scooter Schmidt 54000.25 I need result of query in MATRIX form like this: Customer |------------ Amounts --------------- Name |Car Cycle Scooter Totals Armstrong 80115.50 0.00 0.00 80115.50 Michelle 36571.85 15000.00 0.00 51571.85 Ronald 0.00 25000.00 98547.52 123547.52 Peterson 0.00 0.00 82658.23 82658.23 Schmidt 45000.65 0.00 54000.25 99000.90 Please help me to acheive the above result in SQL Server 2005. Using mulitple views or even temporory tables is fine for me.

    Read the article

  • Convert in memory POCO objects to c# code to initialize

    - by sidesinger
    Is there a library or code sample for converting an in memory POCO c# object to a .cs code file that creates that object. An example: object of type car in memory becomes: Car c = new Car { Name = "mazda", Id = 5, Passengers = new List<string> { "Bob", "Sally" } // etc... recursing to the bottom }; I could assume it could only set public properties.

    Read the article

  • Cakephp: Correct way to resolve hasMany - hasMany relation

    - by Chris
    I have three models: Company, Car, Passenger Company hasMany Cars Car hasMany Passenger These relations seem to work independetly: Car shows all Passengers and Company shows all Cars. But I cannot resolve the Company - Passenger (Show all Passengers of a Company). My controller for Company: function index(){ //grab all companies and pass it to the view: $companies = $this->Company->find('all'); $this->set('companies', $companies); } This displays all companies with all their respective cars. However the array does not contain an entry for passenger. What do I have to do to completely resovle the Company - Car - Passenger relation?

    Read the article

  • Java - getConstructor() ?

    - by msr
    Hello, I wrote the question as a comment in the code, I think its easier to understand this way. public class Xpto{ protected AbstractClass x; public void foo(){ // AbstractClass y = new ????? Car or Person ????? /* here I need a new object of this.x's type (which could be Car or Person) I know that with x.getClass() I get the x's Class (which will be Car or Person), however Im wondering how can I get and USE it's contructor */ // ... more operations (which depend on y's type) } } public abstract class AbstractClass { } public class Car extends AbstractClass{ } public class Person extends AbstractClass{ }

    Read the article

  • question/problem regarding assigning an array of char *

    - by Fantastic Fourier
    Hi I'm working with C and I have a question about assigning pointers. struct foo { int _bar; char * _car[MAXINT]; // this is meant to be an array of char * so that it can hold pointers to names of cars } int foofunc (void * arg) { int bar; char * car[MAXINT]; struct foo thing = (struct foo *) arg; bar = arg->_bar; // this works fine car = arg->_car; // this gives compiler errors of incompatible types in assignment } car and _car have same declaration so why am I getting an error about incompatible types? My guess is that it has something to do with them being pointers (because they are pointers to arrays of char *, right?) but I don't see why that is a problem. when i declared char * car; instead of char * car[MAXINT]; it compiles fine. but I don't see how that would be useful to me later when I need to access certain info using index, it would be very annoying to access that info later. in fact, I'm not even sure if I am going about the right way, maybe there is a better way to store a bunch of strings instead of using array of char *?

    Read the article

  • Returning a complex data type from arguments with Rhino Mocks

    - by Joseph
    I'm trying to set up a stub with Rhino Mocks which returns a value based on what the parameter of the argument that is passed in. Example: //Arrange var car = new Car(); var provider= MockRepository.GenerateStub<IDataProvider>(); provider.Stub( x => x.GetWheelsWithSize(Arg<int>.Is.Anything)) .Return(new List<IWheel> { new Wheel { Size = ?, Make = Make.Michelin }, new Wheel { Size = ?, Make = Make.Firestone } }); car.Provider = provider; //Act car.ReplaceTires(); //Assert that the right tire size was used when replacing the tires The problem is that I want Size to be whatever was passed into the method, because I'm actually asserting later that the wheels are the right size. This is not to prove that the data provider works obviously since I stubbed it, but rather to prove that the correct size was passed in. How can I do this?

    Read the article

  • Which method should I use ?

    - by Ivan
    I want to do this exercise but I don't know exactly which method should I use for an exercise like this and what data will I use to test the algorithm. The driving distance between Perth and Adelaide is 1996 miles. On the average, the fuel consumption of a 2.0 litre 4 cylinder car is 8 litres per 100 kilometres. The fuel tank capacity of such a car is 60 litres. Design and implement a JAVA program that prompts for the fuel consumption and fuel tank capacity of the aforementioned car. The program then displays the minimum number of times the car’s fuel tank has to be filled up to drive from Perth to Adelaide. Note that 62 miles is equal to 100 kilometres. What data will you use to test that your algorithm works correctly?

    Read the article

  • c incompatible types in assignment, problem with pointers?

    - by Fantastic Fourier
    Hi I'm working with C and I have a question about assigning pointers. struct foo { int _bar; char * _car[MAXINT]; // this is meant to be an array of char * so that it can hold pointers to names of cars } int foofunc (void * arg) { int bar; char * car[MAXINT]; struct foo thing = (struct foo *) arg; bar = arg->_bar; // this works fine car = arg->_car; // this gives compiler errors of incompatible types in assignment } car and _car have same declaration so why am I getting an error about incompatible types? My guess is that it has something to do with them being pointers (because they are pointers to arrays of char *, right?) but I don't see why that is a problem. when i declared char * car; instead of char * car[MAXINT]; it compiles fine. but I don't see how that would be useful to me later when I need to access certain info using index, it would be very annoying to access that info later. in fact, I'm not even sure if I am going about the right way, maybe there is a better way to store a bunch of strings instead of using array of char *?

    Read the article

  • Algorithm for optimally choosing actions to perform a task

    - by Jules
    There are two data types: tasks and actions. An action costs a certain time to complete, and a set of tasks this actions consists of. A task has a set of actions, and our job is to choose one of them. So: class Task { Set<Action> choices; } class Action { float time; Set<Task> dependencies; } For example the primary task could be "Get a house". The possible actions for this task: "Buy a house" or "Build a house". The action "Build a house" costs 10 hours and has the dependencies "Get bricks" and "Get cement", etcetera. The total time is the sum of all the times of the actions required to perform. We want to choose actions such that the total time is minimal. Note that the dependencies can be diamond shaped. For example "Get bricks" could require "Get a car" (to transport the bricks) and "Get cement" would also require a car. Even if you do "Get bricks" and "Get cement" you only have to count the time it takes to get a car once. Note also that the dependencies can be circular. For example "Money" - "Job" - "Car" - "Money". This is no problem for us, we simply select all of "Money", "Job" and "Car". The total time is simply the sum of the time of these 3 things. Mathematical description: Let actions be the chosen actions. valid(task) = ?action ? task.choices. (action ? actions ? ?tasks ? action.dependencies. valid(task)) time = sum {action.time | action ? actions} minimize time subject to valid(primaryTask)

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >