Search Results

Search found 6328 results on 254 pages for 'anonymous person'.

Page 1/254 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Improving first person camera and implementing third person camera

    - by brainydexter
    I want to improve upon my first person camera implementation and extend it to, so the user can toggle between third person/first person view. My current setup: draw():: glPushMatrix(); m_pCamera->ApplyCameraTransform(); // Render gameObjects glPopMatrix(); Camera is strongly coupled to the player, so much so, that it is a friend of player. This is what the Camera::ApplyCameraTransform looks like: glm::mat4 l_TransformationMatrix; m_pPlayer->m_pTransformation->GetTransformation(l_TransformationMatrix, false); l_TransformationMatrix = glm::core::function::matrix::inverse(l_TransformationMatrix); glMultMatrixf(glm::value_ptr(l_TransformationMatrix)); So, I take the player's transformation matrix and invert it to yield First person camera view. Since, Third person camera view is just a 'translated' first person view behind the player; what would be a good way to improve upon this (keeping in mind that I will be extending it to Third person camera as well. Thanks

    Read the article

  • The Best Free Online First Person Shooter (FPS) Games

    - by Lori Kaufman
    First Person Shooter (FPS) games are action games centered around gun and projectile weapon-based combat. As the player, you experience the action directly through the eyes of the protagonist. FPS games have become a very popular type of game online. A lot of FPS games are paid, but there are many you can play for free. Most FPS games have online versions where you play in a supported browser or download a program for your PC that allows you to connect to the game online. We have collected links and information about some of the more popular free FPS games available. All the games listed here are free to play, but there may be some limitations, and you have to register for many of them and download game clients to your computer to be able to connect to the game online. Secure Yourself by Using Two-Step Verification on These 16 Web Services How to Fix a Stuck Pixel on an LCD Monitor How to Factory Reset Your Android Phone or Tablet When It Won’t Boot

    Read the article

  • C#/.NET Little Wonders: The Joy of Anonymous Types

    - by James Michael Hare
    Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. In the .NET 3 Framework, Microsoft introduced the concept of anonymous types, which provide a way to create a quick, compiler-generated types at the point of instantiation.  These may seem trivial, but are very handy for concisely creating lightweight, strongly-typed objects containing only read-only properties that can be used within a given scope. Creating an Anonymous Type In short, an anonymous type is a reference type that derives directly from object and is defined by its set of properties base on their names, number, types, and order given at initialization.  In addition to just holding these properties, it is also given appropriate overridden implementations for Equals() and GetHashCode() that take into account all of the properties to correctly perform property comparisons and hashing.  Also overridden is an implementation of ToString() which makes it easy to display the contents of an anonymous type instance in a fairly concise manner. To construct an anonymous type instance, you use basically the same initialization syntax as with a regular type.  So, for example, if we wanted to create an anonymous type to represent a particular point, we could do this: 1: var point = new { X = 13, Y = 7 }; Note the similarity between anonymous type initialization and regular initialization.  The main difference is that the compiler generates the type name and the properties (as readonly) based on the names and order provided, and inferring their types from the expressions they are assigned to. It is key to remember that all of those factors (number, names, types, order of properties) determine the anonymous type.  This is important, because while these two instances share the same anonymous type: 1: // same names, types, and order 2: var point1 = new { X = 13, Y = 7 }; 3: var point2 = new { X = 5, Y = 0 }; These similar ones do not: 1: var point3 = new { Y = 3, X = 5 }; // different order 2: var point4 = new { X = 3, Y = 5.0 }; // different type for Y 3: var point5 = new {MyX = 3, MyY = 5 }; // different names 4: var point6 = new { X = 1, Y = 2, Z = 3 }; // different count Limitations on Property Initialization Expressions The expression for a property in an anonymous type initialization cannot be null (though it can evaluate to null) or an anonymous function.  For example, the following are illegal: 1: // Null can't be used directly. Null reference of what type? 2: var cantUseNull = new { Value = null }; 3:  4: // Anonymous methods cannot be used. 5: var cantUseAnonymousFxn = new { Value = () => Console.WriteLine(“Can’t.”) }; Note that the restriction on null is just that you can’t use it directly as the expression, because otherwise how would it be able to determine the type?  You can, however, use it indirectly assigning a null expression such as a typed variable with the value null, or by casting null to a specific type: 1: string str = null; 2: var fineIndirectly = new { Value = str }; 3: var fineCast = new { Value = (string)null }; All of the examples above name the properties explicitly, but you can also implicitly name properties if they are being set from a property, field, or variable.  In these cases, when a field, property, or variable is used alone, and you don’t specify a property name assigned to it, the new property will have the same name.  For example: 1: int variable = 42; 2:  3: // creates two properties named varriable and Now 4: var implicitProperties = new { variable, DateTime.Now }; Is the same type as: 1: var explicitProperties = new { variable = variable, Now = DateTime.Now }; But this only works if you are using an existing field, variable, or property directly as the expression.  If you use a more complex expression then the name cannot be inferred: 1: // can't infer the name variable from variable * 2, must name explicitly 2: var wontWork = new { variable * 2, DateTime.Now }; In the example above, since we typed variable * 2, it is no longer just a variable and thus we would have to assign the property a name explicitly. ToString() on Anonymous Types One of the more trivial overrides that an anonymous type provides you is a ToString() method that prints the value of the anonymous type instance in much the same format as it was initialized (except actual values instead of expressions as appropriate of course). For example, if you had: 1: var point = new { X = 13, Y = 42 }; And then print it out: 1: Console.WriteLine(point.ToString()); You will get: 1: { X = 13, Y = 42 } While this isn’t necessarily the most stunning feature of anonymous types, it can be handy for debugging or logging values in a fairly easy to read format. Comparing Anonymous Type Instances Because anonymous types automatically create appropriate overrides of Equals() and GetHashCode() based on the underlying properties, we can reliably compare two instances or get hash codes.  For example, if we had the following 3 points: 1: var point1 = new { X = 1, Y = 2 }; 2: var point2 = new { X = 1, Y = 2 }; 3: var point3 = new { Y = 2, X = 1 }; If we compare point1 and point2 we’ll see that Equals() returns true because they overridden version of Equals() sees that the types are the same (same number, names, types, and order of properties) and that the values are the same.   In addition, because all equal objects should have the same hash code, we’ll see that the hash codes evaluate to the same as well: 1: // true, same type, same values 2: Console.WriteLine(point1.Equals(point2)); 3:  4: // true, equal anonymous type instances always have same hash code 5: Console.WriteLine(point1.GetHashCode() == point2.GetHashCode()); However, if we compare point2 and point3 we get false.  Even though the names, types, and values of the properties are the same, the order is not, thus they are two different types and cannot be compared (and thus return false).  And, since they are not equal objects (even though they have the same value) there is a good chance their hash codes are different as well (though not guaranteed): 1: // false, different types 2: Console.WriteLine(point2.Equals(point3)); 3:  4: // quite possibly false (was false on my machine) 5: Console.WriteLine(point2.GetHashCode() == point3.GetHashCode()); Using Anonymous Types Now that we’ve created instances of anonymous types, let’s actually use them.  The property names (whether implicit or explicit) are used to access the individual properties of the anonymous type.  The main thing, once again, to keep in mind is that the properties are readonly, so you cannot assign the properties a new value (note: this does not mean that instances referred to by a property are immutable – for more information check out C#/.NET Fundamentals: Returning Data Immutably in a Mutable World). Thus, if we have the following anonymous type instance: 1: var point = new { X = 13, Y = 42 }; We can get the properties as you’d expect: 1: Console.WriteLine(“The point is: ({0},{1})”, point.X, point.Y); But we cannot alter the property values: 1: // compiler error, properties are readonly 2: point.X = 99; Further, since the anonymous type name is only known by the compiler, there is no easy way to pass anonymous type instances outside of a given scope.  The only real choices are to pass them as object or dynamic.  But really that is not the intention of using anonymous types.  If you find yourself needing to pass an anonymous type outside of a given scope, you should really consider making a POCO (Plain Old CLR Type – i.e. a class that contains just properties to hold data with little/no business logic) instead. Given that, why use them at all?  Couldn’t you always just create a POCO to represent every anonymous type you needed?  Sure you could, but then you might litter your solution with many small POCO classes that have very localized uses. It turns out this is the key to when to use anonymous types to your advantage: when you just need a lightweight type in a local context to store intermediate results, consider an anonymous type – but when that result is more long-lived and used outside of the current scope, consider a POCO instead. So what do we mean by intermediate results in a local context?  Well, a classic example would be filtering down results from a LINQ expression.  For example, let’s say we had a List<Transaction>, where Transaction is defined something like: 1: public class Transaction 2: { 3: public string UserId { get; set; } 4: public DateTime At { get; set; } 5: public decimal Amount { get; set; } 6: // … 7: } And let’s say we had this data in our List<Transaction>: 1: var transactions = new List<Transaction> 2: { 3: new Transaction { UserId = "Jim", At = DateTime.Now, Amount = 2200.00m }, 4: new Transaction { UserId = "Jim", At = DateTime.Now, Amount = -1100.00m }, 5: new Transaction { UserId = "Jim", At = DateTime.Now.AddDays(-1), Amount = 900.00m }, 6: new Transaction { UserId = "John", At = DateTime.Now.AddDays(-2), Amount = 300.00m }, 7: new Transaction { UserId = "John", At = DateTime.Now, Amount = -10.00m }, 8: new Transaction { UserId = "Jane", At = DateTime.Now, Amount = 200.00m }, 9: new Transaction { UserId = "Jane", At = DateTime.Now, Amount = -50.00m }, 10: new Transaction { UserId = "Jaime", At = DateTime.Now.AddDays(-3), Amount = -100.00m }, 11: new Transaction { UserId = "Jaime", At = DateTime.Now.AddDays(-3), Amount = 300.00m }, 12: }; So let’s say we wanted to get the transactions for each day for each user.  That is, for each day we’d want to see the transactions each user performed.  We could do this very simply with a nice LINQ expression, without the need of creating any POCOs: 1: // group the transactions based on an anonymous type with properties UserId and Date: 2: byUserAndDay = transactions 3: .GroupBy(tx => new { tx.UserId, tx.At.Date }) 4: .OrderBy(grp => grp.Key.Date) 5: .ThenBy(grp => grp.Key.UserId); Now, those of you who have attempted to use custom classes as a grouping type before (such as GroupBy(), Distinct(), etc.) may have discovered the hard way that LINQ gets a lot of its speed by utilizing not on Equals(), but also GetHashCode() on the type you are grouping by.  Thus, when you use custom types for these purposes, you generally end up having to write custom Equals() and GetHashCode() implementations or you won’t get the results you were expecting (the default implementations of Equals() and GetHashCode() are reference equality and reference identity based respectively). As we said before, it turns out that anonymous types already do these critical overrides for you.  This makes them even more convenient to use!  Instead of creating a small POCO to handle this grouping, and then having to implement a custom Equals() and GetHashCode() every time, we can just take advantage of the fact that anonymous types automatically override these methods with appropriate implementations that take into account the values of all of the properties. Now, we can look at our results: 1: foreach (var group in byUserAndDay) 2: { 3: // the group’s Key is an instance of our anonymous type 4: Console.WriteLine("{0} on {1:MM/dd/yyyy} did:", group.Key.UserId, group.Key.Date); 5:  6: // each grouping contains a sequence of the items. 7: foreach (var tx in group) 8: { 9: Console.WriteLine("\t{0}", tx.Amount); 10: } 11: } And see: 1: Jaime on 06/18/2012 did: 2: -100.00 3: 300.00 4:  5: John on 06/19/2012 did: 6: 300.00 7:  8: Jim on 06/20/2012 did: 9: 900.00 10:  11: Jane on 06/21/2012 did: 12: 200.00 13: -50.00 14:  15: Jim on 06/21/2012 did: 16: 2200.00 17: -1100.00 18:  19: John on 06/21/2012 did: 20: -10.00 Again, sure we could have just built a POCO to do this, given it an appropriate Equals() and GetHashCode() method, but that would have bloated our code with so many extra lines and been more difficult to maintain if the properties change.  Summary Anonymous types are one of those Little Wonders of the .NET language that are perfect at exactly that time when you need a temporary type to hold a set of properties together for an intermediate result.  While they are not very useful beyond the scope in which they are defined, they are excellent in LINQ expressions as a way to create and us intermediary values for further expressions and analysis. Anonymous types are defined by the compiler based on the number, type, names, and order of properties created, and they automatically implement appropriate Equals() and GetHashCode() overrides (as well as ToString()) which makes them ideal for LINQ expressions where you need to create a set of properties to group, evaluate, etc. Technorati Tags: C#,CSharp,.NET,Little Wonders,Anonymous Types,LINQ

    Read the article

  • Starcraft 2 - Third Person Custom Map

    - by Norla
    I would like to try my hand at creating a custom map in Starcraft 2 that has a third-person camera follow an individual unit. There are a few custom maps that exist with this feature already, so I do know this is possible. What I'm having trouble wrapping my head around are the features that are new to the SC2 map editor that didn't exist in the Warcraft 3 editor. For instance, to do a third-person map, do I need a custom mods file, or can everything be done in the map file? Regardless, is it worth using a mod file? What map settings do I NEED to edit/implement? Which are not necessary, but recommended?

    Read the article

  • Who owns code if its written by one person with another person directing [on hold]

    - by user136226
    I have an Issue that I need some info on. Basically what Im looking to find out is if I create software,and someone else gives me direction on what they want the software to look like,e.g. an image here,this font of text and it must behave in a certain way. Also some of the code was not developed on my computer and there is no official agreement in place. Not looking to screw anyone over here but need to protect myself if things go sour. Do I own the software or is it jointly owned? Thanks

    Read the article

  • Improve mouse movement in First person game

    - by brainydexter
    In my current FPS game, I have the mouse setup in a way, that it always forces the position of the mouse to be centered at the screen. This gets the job done, but also gets very annoying, since the mouse is "fixed" at the center of the screen. Here is what I am doing: get mouse current position find offset from center of the screen set mouse current position to center of the screen apply difference to m_pTransformation (transformation matrix of the player) Is there a better way to deal with this ?

    Read the article

  • Allow anonymous upload for Vsftpd?

    - by user15318
    I need a basic FTP server on Linux (CentOS 5.5) without any security measure, since the server and the clients are located on a test LAN, not connected to the rest of the network, which itself uses non-routable IP's behind a NAT firewall with no incoming access to FTP. Some people recommend Vsftpd over PureFTPd or ProFTPd. No matter what I try, I can't get it to allow an anonymous user (ie. logging as "ftp" or "anonymous" and typing any string as password) to upload a file: # yum install vsftpd # mkdir /var/ftp/pub/upload # cat vsftpd.conf listen=YES anonymous_enable=YES local_enable=YES write_enable=YES xferlog_file=YES #anonymous users are restricted (chrooted) to anon_root #directory was created by root, hence owned by root.root anon_root=/var/ftp/pub/incoming anon_upload_enable=YES anon_mkdir_write_enable=YES #chroot_local_user=NO #chroot_list_enable=YES #chroot_list_file=/etc/vsftpd.chroot_list chown_uploads=YES When I log on from a client, here's what I get: 500 OOPS: cannot change directory:/var/ftp/pub/incoming I also tried "# chmod 777 /var/ftp/incoming/", but get the same error. Does someone know how to configure Vsftpd with minimum security? Thank you. Edit: SELinux is disabled and here are the file permissions: # cat /etc/sysconfig/selinux SELINUX=disabled SELINUXTYPE=targeted SETLOCALDEFS=0 # sestatus SELinux status: disabled # getenforce Disabled # grep ftp /etc/passwd ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin # ll /var/ drwxr-xr-x 4 root root 4096 Mar 14 10:53 ftp # ll /var/ftp/ drwxrwxrwx 2 ftp ftp 4096 Mar 14 10:53 incoming drwxr-xr-x 3 ftp ftp 4096 Mar 14 11:29 pub Edit: latest vsftpd.conf: listen=YES local_enable=YES write_enable=YES xferlog_file=YES #anonymous users are restricted (chrooted) to anon_root anonymous_enable=YES anon_root=/var/ftp/pub/incoming anon_upload_enable=YES anon_mkdir_write_enable=YES #500 OOPS: bad bool value in config file for: chown_uploads chown_uploads=YES chown_username=ftp Edit: with trailing space removed from "chown_uploads", err 500 is solved, but anonymous still doesn't work: client> ./ftp server Connected to server. 220 (vsFTPd 2.0.5) Name (server:root): ftp 331 Please specify the password. Password: 500 OOPS: cannot change directory:/var/ftp/pub/incoming Login failed. ftp> bye With user "ftp" listed in /etc/passwd with home directory set to "/var/ftp" and access rights to /var/ftp set to "drwxr-xr-x" and /var/ftp/incoming to "drwxrwxrwx"...could it be due to PAM maybe? I don't find any FTP log file in /var/log to investigate. Edit: Here's a working configuration to let ftp/anonymous connect and upload files to /var/ftp: listen=YES anonymous_enable=YES write_enable=YES anon_upload_enable=YES anon_mkdir_write_enable=YES

    Read the article

  • Anonymous methods/functions: a fundamental feature or a violation of OO principles?

    - by RD1
    Is the recent movement towards anonymous methods/functions by mainstream languages like perl and C# something important, or a weird feature that violates OO principles? Are recent libraries like the most recent version of Intel's Thread Building Blocks and Microsofts PPL and Linq that depend on such things a good thing, or not? Are languages that currently reject anonymous methods/functions, like Java, making wise choices in sticking with a purely OO model, or are they falling behind by lacking a fundamental programming feature?

    Read the article

  • Prevent anonymous access to form and application pages in SharePoint 2010

    - by shehan
    When you create a Publishing site that has anonymous access enabled, you will notice that anonymous users will not be able to access pages that reside in the “_layouts” virtual directory (e.g. http://siteX/_layouts/viewlsts.aspx). This is because the publishing infrastructure activates a hidden feature that prevents anonymous users from accessing these types of pages. However, if you were to create a site collection based of  Blank Site Template, you would notice that these pages are accessible by anonymous users. The fix is quite simple. There is a hidden feature that you would need to manually activate via stsadm. The feature is called “ViewFormPagesLockDown” (and is available in the Features folders in the 14 hive) To activate it: stsadm -o activatefeature -filename ViewFormPagesLockDown\feature.xml -url http://ServerName Once activated anonymous users will be promoted to enter credentials when they try to access form and application pages. The feature can also be deactivated for publishing sites that have it automatically turned on.   Technorati Tags: SharePoint 2010,anonymous,lockdown,pages,security

    Read the article

  • DNS down in Anonymous attack

    - by Tal Weiss
    As I'm writing this our company website and the web-service we developed are down in the big GoDaddy outage resulting from an Anonymous attack (or so says Twitter). We used GoDaddy as our registrar and we use it for DNS for some domains. Tomorrow is a new day - what can we do to mitigate such outages? Simply moving to, say, Route 53 for DNS might not be enough. Is there any way to remove this single point of failure?

    Read the article

  • Unity - Mecanim & Rigidbody on Third Person Controller - Gravity bug?

    - by Celtc
    I'm working on a third person controller which uses physX to interact with the other objects (using the Rigidbody component) and Mecanim to animate the character. All the animations used are baked to Y, and the movement on this axis is controlled by the gravity applied by the rigidbody component. The configuration of the falling animation: And the character components configuration: Since the falling animation doesn't have root motion on XZ, I move the character on XZ by code. Like this: // On the Ground if (IsGrounded()) { GroundedMovementMgm(); // Stores the velocity velocityPreFalling = rigidbody.velocity; } // Mid-Air else { // Continue the pre falling velocity rigidbody.velocity = new Vector3(velocityPreFalling.x, rigidbody.velocity.y, velocityPreFalling.z); } The problem is that when the chracter starts falling and hit against a wall in mid air, it gets stuck to the wall. Here are some pics which explains the problems: Hope someone can help me. Thanks and sory for my bad english! PD.: I was asked for the IsGrounded() function, so I'm adding it: void OnCollisionEnter(Collision collision) { if (!grounded) TrackGrounded(collision); } void OnCollisionStay(Collision collision) { TrackGrounded(collision); } void OnCollisionExit() { grounded = false; } public bool IsGrounded() { return grounded; } private void TrackGrounded(Collision collision) { var maxHeight = capCollider.bounds.min.y + capCollider.radius * .9f; foreach (var contact in collision.contacts) { if (contact.point.y < maxHeight && Vector3.Angle(contact.normal, Vector3.up) < maxSlopeAngle) { grounded = true; break; } } } I'll also add a LINK to download the project if someone wants it.

    Read the article

  • How do I have to take into account the direction in which the camera is facing when creating a first person strafe (left/right) movement

    - by Chris
    This is the code I am currently using, and it works great, except for the strafe always causes the camera to move along the X axis which is not relative to the direction in which the camera is actually facing. As you can see currently only the x location is updated: [delta * -1, 0, 0] How should I take into account the direction in which the camera is facing (I have the camera's target x,y,z) when creating a first person strafe (left/right) movement? case 'a': var eyeOriginal = g_eye; var targetOriginal = g_target; var viewEye = g_math.subVector(g_eye, g_target); var viewTarget = g_math.subVector(g_target, g_eye); viewEye = g_math.addVector([delta * -1, 0, 0], viewEye); viewTarget = g_math.addVector([delta * -1, 0, 0], viewTarget); g_eye = g_math.addVector(viewEye, targetOriginal); g_target = g_math.addVector(viewTarget, eyeOriginal); break; case 'd': var eyeOriginal = g_eye; var targetOriginal = g_target; var viewEye = g_math.subVector(g_eye, g_target); var viewTarget = g_math.subVector(g_target, g_eye); viewEye = g_math.addVector([delta, 0, 0], viewEye); viewTarget = g_math.addVector([delta, 0, 0], viewTarget); g_eye = g_math.addVector(viewEye, targetOriginal); g_target = g_math.addVector(viewTarget, eyeOriginal); break;

    Read the article

  • JS: variable inheritance in anonymous functions - scope

    - by tkSimon
    hey guys, someone from doctype sent me here. long story short: var o="before"; x = function() //this needs to be an anonymous function { alert(o); //the variable "o" is from the parent scope }; o="after"; //this chages "o" in the anonymous function x(); //this results in in alert("after"); //which is not the way i want/need it in reality my code is somewhat more complex. my script iterates through many html objects and adds an event listener each element. i do this by declaring an anonymous function for each element and call another function with an ID as argument. that ID is represented by the "o"-variable in this example. after some thinking i understand why it is the way it is, but is there a way to get js to evaluate o as i declare the anonymous function without dealing with the id attribute and fetching my ID from there? my full source code is here: http://pastebin.com/GMieerdw the anonymous function is on line 303

    Read the article

  • Office documents prompt for login in anonymous SharePoint site

    - by xmt15
    I have a MOSS 07 site that is configured for anonymous access. There is a document library within this site that also has anonymous access enabled. When an anonymous user clicks on a PDF file in this library, he or she can read or download it with no problem. When a user clicks on an Office document, he or she is prompted with a login box. The user can cancel out of this box without entering a log in, and will be taken to the document. This happens in IE but not FireFox. I see some references to this question on the web but no clear solutions: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.sharepoint.windowsservices.development&tid=5452e093-a0d7-45c5-8ed0-96551e854cec&cat=en_US_CC8402B4-DC5E-652D-7DB2-0119AFB7C906&lang=en&cr=US&sloc=&p=1 http://www.sharepointu.com/forums/t/5779.aspx http://www.eggheadcafe.com/software/aspnet/30817418/anonymous-users-getting-p.aspx

    Read the article

  • Invoke a subclass method of an anonymous class

    - by arjacsoh
    I am trying right now to dig into anonymous classes and one question was just arised I 'd prefer not to refer to much details and to pose my question straightforward: How can I invoke the method sizzle() in the following anonymous class: public class Popcorn { public void pop() { System.out.println("popcorn"); } } class Food { Popcorn p = new Popcorn() { public void sizzle() { System.out.println("anonymous sizzling popcorn"); } public void pop() { System.out.println("anonymous popcorn"); } }; public void popIt() { p.pop(); // OK, Popcorn has a pop() method p.sizzle(); // Not Legal! Popcorn does not have sizzle() } } It is known and definite in polymorphism rules that a refernce of a superclass cannot invoke methods of subclass without downcasting (even if it refers to an object of the given subclass). However in the above case what is the "key" to invoke the sizzle() method?

    Read the article

  • Passing a comparator syntax help in Java

    - by Crystal
    I've tried this a couple ways, the first is have a class that implements comparator at the bottom of the following code. When I try to pass the comparat in sortListByLastName, I get a constructor not found error and I am not sure why import java.util.*; public class OrganizeThis implements WhoDoneIt { /** Add a person to the organizer @param p A person object */ public void add(Person p) { staff.put(p.getEmail(), p); //System.out.println("Person " + p + "added"); } /** * Remove a Person from the organizer. * * @param email The email of the person to be removed. */ public void remove(String email) { staff.remove(email); } /** * Remove all contacts from the organizer. * */ public void empty() { staff.clear(); } /** * Find the person stored in the organizer with the email address. * Note, each person will have a unique email address. * * @param email The person email address you are looking for. * */ public Person findByEmail(String email) { Person aPerson = staff.get(email); return aPerson; } /** * Find all persons stored in the organizer with the same last name. * Note, there can be multiple persons with the same last name. * * @param lastName The last name of the persons your are looking for. * */ public Person[] find(String lastName) { ArrayList<Person> names = new ArrayList<Person>(); for (Person s : staff.values()) { if (s.getLastName() == lastName) { names.add(s); } } // Convert ArrayList back to Array Person nameArray[] = new Person[names.size()]; names.toArray(nameArray); return nameArray; } /** * Return all the contact from the orgnizer in * an array sorted by last name. * * @return An array of Person objects. * */ public Person[] getSortedListByLastName() { PersonLastNameComparator comp = new PersonLastNameComparator(); Map<String, Person> sorted = new TreeMap<String, Person>(comp); ArrayList<Person> sortedArrayList = new ArrayList<Person>(); for (Person s: sorted.values()) { sortedArrayList.add(s); } Person sortedArray[] = new Person[sortedArrayList.size()]; sortedArrayList.toArray(sortedArray); return sortedArray; } private Map<String, Person> staff = new HashMap<String, Person>(); public static void main(String[] args) { OrganizeThis testObj = new OrganizeThis(); Person person1 = new Person("J", "W", "111-222-3333", "[email protected]"); Person person2 = new Person("K", "W", "345-678-9999", "[email protected]"); Person person3 = new Person("Phoebe", "Wang", "322-111-3333", "[email protected]"); Person person4 = new Person("Nermal", "Johnson", "322-342-5555", "[email protected]"); Person person5 = new Person("Apple", "Banana", "123-456-1111", "[email protected]"); testObj.add(person1); testObj.add(person2); testObj.add(person3); testObj.add(person4); testObj.add(person5); System.out.println(testObj.findByEmail("[email protected]")); System.out.println("------------" + '\n'); Person a[] = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("------------" + '\n'); a = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("SORTED" + '\n'); a = testObj.getSortedListByLastName(); for (Person b : a) { System.out.println(b); } System.out.println(testObj.getAuthor()); } } class PersonLastNameComparator implements Comparator<Person> { public int compare(Person a, Person b) { return a.getLastName().compareTo(b.getLastName()); } } And then when I tried doing it by creating an anonymous inner class, I also get a constructor TreeMap cannot find symbol error. Any thoughts? inner class method: public Person[] getSortedListByLastName() { //PersonLastNameComparator comp = new PersonLastNameComparator(); Map<String, Person> sorted = new TreeMap<String, Person>(new Comparator<Person>() { public int compare(Person a, Person b) { return a.getLastName().compareTo(b.getLastName()); } }); ArrayList<Person> sortedArrayList = new ArrayList<Person>(); for (Person s: sorted.values()) { sortedArrayList.add(s); } Person sortedArray[] = new Person[sortedArrayList.size()]; sortedArrayList.toArray(sortedArray); return sortedArray; }

    Read the article

  • Cannot iterate of a collection of Anonymous Types created from a LINQ Query in VB.NET

    - by Atari2600
    Ok everyone, I must be missing something here. Every LINQ example I have seen for VB.NET anonymous types claims I can do something like this: Dim Info As EnumerableRowCollection = pDataSet.Tables(0).AsEnumerable Dim Infos = From a In Info _ Select New With {.Prop1 = a("Prop1"), .Prop2 = a("Prop2"), .Prop3 = a("Prop3") } Now when I go to iterate through the collection(see example below), I get an error that says "Name "x" is not declared. For Each x in Infos ... Next It's like VB.NET doesn't understand that Infos is a collection of anonymous types created by LINQ and wants me to declare "x" as some type. (Wouldn't this defeat the purpose of an anonymous type?) I have added the references to System.Data.Linq and System.Data.DataSetExtensions to my project. Here is what I am importing with the class: Imports System.Linq Imports System.Linq.Enumerable Imports System.Linq.Queryable Imports System.Data.Linq Any ideas?

    Read the article

  • CascadingDropDownList not working with anonymous access

    - by Alessandro
    Hi everyone, I use a CascadingDropDownList of the AJAXControlToolkit in a ASP.NET MCMS 2002 web application. The CascadingDropDownList works as expected until "Anonymous access" and "Integrated Windows Authentication" flags are both checked (and this is the situation in the production environment) in the Directory Security settings on the website under IIS. The error I get is: 500 Internal Server Error No web service found at: If I uncheck the anonymous access or the windows authentication everything is ok. Any suggestions?

    Read the article

  • convert the output into an list

    - by prince23
    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Xml.XPath; using System.Xml.Linq; namespace SampleProgram1 { class Program { static void Main(string[] args) { string xml = @"<people> <person><name>kumar</name><school>fes</school><parent>All</parent></person> <person><name>manju</name><school>fes</school><parent>kumar</parent></person> <person><name>anu</name><school>frank</school><parent>kumar</parent></person> <person><name>anitha</name><school>jss</school><parent>All</parent></person> <person><name>rohit</name><school>frank</school><parent>manju</parent></person> <person><name>anill</name><school>vijaya</school><parent>manju</parent></person> <person><name>vani</name><school>jss</school><parent>kumar</parent></person> <person><name>soumya</name><school>jss</school><parent>kumar</parent></person> <person><name>madhu</name><school>jss</school><parent>rohit</parent></person> <person><name>shiva</name><school>jss</school><parent>rohit</parent></person> <person><name>vanitha</name><school>jss</school><parent>anitha</parent></person> <person><name>anu</name><school>jss</school><parent>anitha</parent></person> </people>"; XDocument document = XDocument.Parse(xml); var people = (from person in document.Descendants("person") select new Person { Name = (string)person.Element("name"), School = (string)person.Element("school"), Parent = (string)person.Element("parent") }).ToList(); var parents = people.Where(p => p.Parent == "All"); Action<Person> findChildren = null; findChildren = person => { List<Person> children = people.Where(p => p.Parent == person.Name).ToList(); person.Children = children; foreach (Person p in children) findChildren(p); }; foreach (Person parent in parents) { findChildren(parent); } Action<Person, int> showChildren = null; showChildren = (person, tabs) => { //Console.WriteLine(new string('\t', tabs) + person.Name); if (person.Children != null) { foreach (Person p in person.Children) showChildren(p, tabs + 1); } }; foreach (Person parent in parents) { showChildren(parent, 0); } // Console.Read(); } } class Person { public string Name { get; set; } public string School { get; set; } public string Parent { get; set; } public List<Person> Children { get; set; } } } this my program where i need to put the output into a list an dthen bind the lsit into gridview can any one help me out in syntax achiveing this one. i am using c# 3.5

    Read the article

  • Silverlight 4 Data Binding with anonymous types.

    - by Anthony
    Does anyone know if you can use data binding with anonymous types in Silverlight 4? I know you can't in previous versions of silverlight, you can only databind to public class properties and anonymous type properties are internal. Just wondering if anyone has tried it in silverlight 4? Thanks in advanced

    Read the article

  • JavaScript check if anonymous object has a method

    - by Baddie
    How can I check if an anonymous object that was created as such: var myObj = { prop1: 'no', prop2: function () { return false; } } does indeed have a prop2 defined? prop2 will always be defined as a function, but for some objects it is not required and will not be defined. I tried what was suggested here: http://stackoverflow.com/questions/595766/how-to-determine-if-native-javascript-object-has-a-property-method but I don't think it works for anonymous objects .

    Read the article

  • Working with anonymous modules in Ruby

    - by Byron Park
    Suppose I make a module as follows: m = Module.new do class C end end Three questions: Other than a reference to m, is there a way I can access C and other things inside m? Can I give a name to the anonymous module after I've created it (just as if I'd typed "module ...")? How do I delete the anonymous module when I'm done with it, such that the constants it defines are no longer present?

    Read the article

  • Convert text file to dictionary or anonymous type object

    - by Robert Harvey
    I have a text file that looks like this: adapter 1: LPe11002 Factory IEEE: 10000000 C97A83FC Non-Volatile WWPN: 10000000 C93D6A8A , WWNN: 20000000 C93D6A8A adapter 2: LPe11002 Factory IEEE: 10000000 C97A83FD Non-Volatile WWPN: 10000000 C93D6A8B , WWNN: 20000000 C93D6A8B Is there a way to get this information into an anonymous type or dictionary object? The final anonymous type might look something like this, if it were composed in C# by hand: new { adapter1 = new { FactoryIEEE = "10000000 C97A83FC", Non-VolatileWWPN = "10000000 C93D6A8A", WWNN = "20000000 C93D6A8A" } adapter2 = new { FactoryIEEE = "10000000 C97A83FD", Non-VolatileWWPN = "10000000 C93D6A8B", WWNN = "20000000 C93D6A8B" } }

    Read the article

  • how to use anonymous generic delegate in C# 2.0

    - by matti
    Hi. I have a class called NTree: class NTree<T> { public NTree(T data) { this.data = data; children = new List<NTree<T>>(); _stopTraverse = false; } ... public void Traverse(NTree<T> node, TreeVisitor<T> visitor) { try { _stopTraverse = false; Traverse(node, visitor); } finally { _stopTraverse = false; } } private void TraverseInternal(NTree<T> node, TreeVisitor<T> visitor) { if (_stopTraverse) return; if (!visitor(node.data)) { _stopTraverse = true; } foreach (NTree<T> kid in node.children) Traverse(kid, visitor); } When I try to use Traverse with anonymous delegate I get: Argument '2': cannot convert from 'anonymous method' to 'NisConverter.TreeVisitor' The code: tTable srcTable = new tTable(); DataRow[] rows; rootTree.Traverse(rootTree, delegate(TableRows tr) { if (tr.TableName == srcTable.mappingname) { rows = tr.Rows; return false; } }); This however produces no errors: static bool TableFinder<TableRows>(TableRows tr) { return true; } ... rootTree.Traverse(rootTree, TableFinder); I have tried to put "arrowhead-parenthisis" and everything to anonymous delegate but it just does not work. Please help me! Thanks & BR -Matti

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >