Search Results

Search found 50973 results on 2039 pages for 'class names'.

Page 25/2039 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Collision between 2 objects of the same class

    - by user1826033
    Okay, so I have an enemy class(With rotation, position, texture and so on). I spawn a few enemies on the screen, they move around, but they overlap each other. So I tried to do a collision check between two enemies of the same class. But no matter what method I try, it isn't quite working. The best thing I tried was: foreach (Enemy enemy1 in enemies) { enemy1Pos = new Vector2(enemy1.position.X, enemy1.position.Y) foreach (Enemy enemy2 in enemies) { enemy2Pos = new Vector2(enemy2.position.X, enemy2.position.Y) if (Vector2.Distance(enemy2Pos, enemy1Pos) < 200) { enemy1Pos += new Vector2((float)(enemy1.Speed * Math.Cos(enemy1.Rotation)), (float)(enemy1.Speed * Math.Sin(enemy1.Rotation))); } } } This is not to exact code, so it might have some mistakes in it. Anyway when i implemented this solution, the enemies were not overlapping so everything was fine on that part. But, they were always moving to the right side of the screen. I've also looked up flocking etc, but I would like to know, how can I detect collision between 2 objects of the same class?

    Read the article

  • java class that simulates a simple database table

    - by ericso
    I have a collection of heterogenous data that I pull from a database table mtable. Then, for every unique value uv in column A, I compute a function of (SELECT * FROM mtable WHERE A=uv). Then I do the same for column B, and column C. There are rather a lot of unique values, so I don't want to hit the db repeatedly - I would rather have a class that replicates some of the functionality (most importantly some version of SELECT WHERE). Additionally, I would like to abstract the column names away from the class definition, if that makes any sense - the constructor should take a list of names as a parameter, and also, I suppose, a list of types (right now this is just a String[], which seems hacky). I'm getting the initial data from a RowSet. I've more or less done this by using a hashmap that maps Strings to lists/arrays of Objects, but I keep getting bogged down in comparisons and types, and am thinking that my current implementation really isn't as clean and clear as it could be. I'm pretty new to java, also, and am not sure if I'm not going down a completely incorrect path. Does anyone have any suggestions?

    Read the article

  • Pass NSURL from One Class To Another

    - by user717452
    In my appDelegate in didFinishLaunchingWithOptions, I have the following: NSURL *url = [NSURL URLWithString:@"http://www.thejenkinsinstitute.com/Journal/"]; NSString *content = [NSString stringWithContentsOfURL:url]; NSString * aString = content; NSMutableArray *substrings = [NSMutableArray new]; NSScanner *scanner = [NSScanner scannerWithString:aString]; [scanner scanUpToString:@"<p>To Download the PDF, " intoString:nil]; // Scan all characters before # while(![scanner isAtEnd]) { NSString *substring = nil; [scanner scanString:@"<p>To Download the PDF, <a href=\"" intoString:nil]; // Scan the # character if([scanner scanUpToString:@"\"" intoString:&substring]) { // If the space immediately followed the #, this will be skipped [substrings addObject:substring]; } [scanner scanUpToString:@"" intoString:nil]; // Scan all characters before next # } // do something with substrings NSString *URLstring = [substrings objectAtIndex:0]; self.theheurl = [NSURL URLWithString:URLstring]; NSLog(@"%@", theheurl); [substrings release]; The console printout for theheurl gives me a valid URL ending in .pdf. In the class I would like to load the URL, I have the following: - (void)viewWillAppear:(BOOL)animated { _appdelegate.theheurl = currentURL; NSLog(@"%@", currentURL); NSLog(@"%@", _appdelegate.theheurl); [worship loadRequest:[NSURLRequest requestWithURL:currentURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]]; timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES]; [super viewWillAppear:YES]; } However, both NSLogs in that class come back null. What am I Doing wrong in getting the NSURL from the AppDelegate to the class to load it?

    Read the article

  • Custom Class to store the properties and passing the class object across the pages - ASP.NEt

    - by NLV
    Hello I've a requirement where i need to pass some objects across the pages. So i created a custom class with all the properties required and created a instance of it and assigned all the properties appropriately. I then put that object in the session and took it the other page. The problem is that even when i set the properties values to the class it is coming as null. I set a breakpoint in the getter-setter and saw that the value itself is coming as null. Code - public class GetDataSetForReports { private Table m_aspTable; private int m_reportID; private string m_accountKey; private string m_siteKey; private string m_imUserName; /// <summary> /// Asp Table containing the filters /// </summary> public Table aspTable { get { return m_aspTable; } set { m_aspTable = aspTable; } } /// <summary> /// Report ID /// </summary> public int reportID { get { return m_reportID; } set { m_reportID = reportID; } } /// <summary> /// All the accounts selected /// </summary> public string accountKey { get { return m_accountKey; } set { m_accountKey = accountKey; } } /// <summary> /// All the sites selected /// </summary> public string siteKey { get { return m_siteKey; } set { m_siteKey = siteKey; } } /// <summary> /// Current User Name /// </summary> public string imUserName { get { return m_imUserName; } set { m_imUserName = imUserName; } } } This is how i'm creating an instance in the page1 and trying to get it in the page2. Page1 Code //Add the objects to the GetDataSetForReports Class GetDataSetForReports oGetDSForReports = new GetDataSetForReports(); oGetDSForReports.aspTable = aspTable; oGetDSForReports.reportID = iReportID; oGetDSForReports.accountKey = AccountKey; oGetDSForReports.siteKey = Sitekey; oGetDSForReports.imUserName = this.imUserName.ToString(); But the values are not getting set at all. The values are not passing to the class (to the setter) at all. Am i making any OOPS blunder? Any ideas? NLV

    Read the article

  • Whois status "pending delete" with expiration date in November 2011???

    - by Sylver
    A friend of mine is in the process of being scammed by a domain registrar and I am trying to sort out the mess. However I could use a hand understanding some of the details. He paid for 2 years of domain name registration on 6 november 2009. The whois record reads: Domain ID:XXXXXXXXXX Domain Name:XXXXXXXXX.ORG Created On:06-Nov-2009 09:23:12 UTC Last Updated On:17-Dec-2010 00:15:10 UTC Expiration Date:06-Nov-2011 09:23:12 UTC Sponsoring Registrar:OnlineNIC Inc. (R64-LROR) Status:CLIENT TRANSFER PROHIBITED Status:HOLD Status:PENDING DELETE SCHEDULED FOR RELEASE Registrant ID:ONLC-XXXXXXX-X Registrant Name:My friend's name ... Registrant Email:Old email The registrar charged a renewal fee a week ago and is now asking an extra $150 to "reclaim" the domain name, even though the domain name is apparently still in my friend's name and it looks like there is still another 10 months before the expiry date. The expiration date on the WhoIs record looks right (Nov 2011), so I don't understand why the domain status says "PENDING DELETE SCHEDULED FOR RELEASE". Can someone explain me better what the deal is and explain what I need to do get the domain name transfered to a more honest registrar? I already have a registrar for my own domain names, been using them for 10 years without problems, so I know where to transfer the domain names to, I just don't know how to proceed.

    Read the article

  • Create dropdown from multi array + PHP class

    - by chris
    Hi there, Well, I am writing class that creates a DOB selection dropdown. I am having figure out the dropdown(), it seems working but not exactly. Code just creates one drop down, and under this dropdown all day, month and year data are in one selection. like: <label> <sup>*</sup>DOB</label> <select name="form_bod_year"> <option value=""/> <option selected="" value="0">1</option> <option value="1">2</option> <option value="2">3</option> <option value="3">4</option> <option value="4">5</option> <option value="5">6</option> .. <option value="29">30</option> <option value="30">31</option> <option value="1">January</option> <option value="2">February</option> .. <option value="11">November</option> <option value="12">December</option> <option selected="" value="0">1910</option> <option value="1">1911</option> .. <option value="98">2008</option> <option value="99">2009</option> <option value="100">2010</option> </select> Here is my code, I wonder that why all datas are in one selection. It has to be tree selction - Day:Month:Year. //dropdown connector class DropDownConnector { var $dropDownsDatas; var $field_label; var $field_name; var $locale; function __construct($dropDownsDatas, $field_label, $field_name, $locale) { $this-dropDownsDatas = $dropDownsDatas; $this-field_label = $field_label; $this-field_name = $field_name; $this-locale = $locale; } function getValue(){ return $_POST[$this-field_name]; } function dropdown(){ $selectedVal = $this-getValue($this-field_name); foreach($this-dropDownsDatas as $keys=$values){ foreach ($values as $key=$value){ $selected = ($key == $selectedVal ? "selected" : "" ); $options .= sprintf('%s',$key,$value); }; }; return $select_start = "$this-field_desc".$options.""; } function getLabel(){ $non_req = $this-getNotRequiredData(); $req = in_array($this-field_name, $non_req) ? '' : '*'; return $this-field_label ? $req . $this-field_label : ''; } function __toString() { $id = $this-field_name; $label = $this-getLabel(); $field = $this-dropdown(); return 'field_name.'"'.$label.''.$field.''; } } function generateForm ($lang,$country_list,$states_list,$days_of_month,$month_list,$years){ $xx = array( 'form_bod_day' = $days_of_month, 'form_bod_month' = $month_list, 'form_bod_year' = $years); echo $dropDownConnector = new DropDownConnector($xx,'DOB','bod','en-US'); } // Call php class to use class on external functionss. $avInq = new formGenerator; $lang='en-US'; echo generateForm ($lang,$country_list,$states_list,$days_of_month,$month_list,$years);

    Read the article

  • How do I delete files in a class?

    - by user3682906
    I want to have a CRUD management on my gallery but I have no idea how. I have searched the internet but I did not find what I was looking for. This is my class: class Gallery { public function renderImages($map) { $images = ""; foreach (glob($map ."*.{jpeg,jpg,png,gif}", GLOB_BRACE) as $image){ $images .= "<a href='".$image."' data-lightbox='afbeelding'><img src='".$image."' class='thumbnail'></img></a>"; } return $images; } } and this is my gallery: <div class="gallery"> <center> <a href="index.php">Back:</a> <style> body { margin:0; padding:0; background:#efefef; font-family: "Helvetica Neue", helvetica, arial, sans-serif; color: black; text-align:center; /* used to center div in IE */ } </style> <?php $gallery = new Gallery(); echo $gallery -> renderImages("../images/"); $connection = new DatabaseConnection(); $render = new RenderData(); $page = 1; if(isset($_GET['page'])) { $check = new CheckData(); if($check->PageCheck($_GET['page'])) { $page = $_GET['page']; } } ?> <table> <div id="Intro"> <tr> <td>Hieronder kan je uploaden.</td> </tr> </div> <tr> <td>Max. 500000000Bytes</td> </tr> <tr> <form action="pages/upload_file.php" method="post" enctype="multipart/form-data"> <td><label for="file">Filename:</label></td> </tr> <tr> <td><input type="file" name="file" id="file"></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <tr> <td><input type="submit" name="delete" value="Delete"></td> </tr> </form> </table> How do I make a CRUD management on this? I want to select the photo and then delete it from my computer. I hope you guys can help me out...

    Read the article

  • Entity framework entity class mapping with plain .net class

    - by Elan
    I have following in entity framework Table - Country Fields List item Country_ID Dialing_Code ISO_Alpha2 ISO_Alpha3 ISO_Full I would like to map only selected fields from this entity model to my domain class. My domain model class is public class DomainCountry { public int Country_ID { get; set; } public string Dialing_Code { get; set; } public string ISO_3166_1_Alpha_2 { get; set; } } The following will work however insert or update is not possible. In order to get insert or update we need to use ObjectSet< but it will not support in my case. IQueryable<DomainCountry> countries = context.Countries.Select( c => new DomainCountry { Country_ID = c.Country_Id, Dialing_Code = c.Dialing_Code, ISO_3166_1_Alpha_2 = c.ISO_3166_1_Alpha_2 }); It will be really fantastic could someone provide a nice solution for this. Ideally it will be kind of proxy class which will support all the futures however highly customizable i.e. only the columns we want to expose to the outer world

    Read the article

  • Problem painting JLabel class to another JPanel class

    - by jjpotter
    I have created a class that extends JLabel to use as my object moving around a JPanel for a game. import javax.swing.*; public class Head extends JLabel { int xpos; int ypos; int xvel; int yvel; ImageIcon chickie = new ImageIcon("C:\\Users\\jjpotter.MSDOM1\\Pictures\\clavalle.jpg"); JLabel myLabel = new JLabel(chickie); public Head(int xpos, int ypos, int xvel, int yvel){ this.xpos = xpos; this.ypos = ypos; this.xvel = xvel; this.yvel = yvel; } public void draw(){ myLabel.setLocation(xpos, ypos); } public double getXpos() { return xpos; } public double getYpos() { return ypos; } public int getXvel() { return xvel; } public int getYvel() { return yvel; } public void setPos(int x, int y){ xpos = x; ypos = y; } } I am then trying to add it onto my JPanel. From here I will randomly have it increment its x and y coordinates to float it around the screen. I can not get it to paint itself onto the JPanel. I know there is a key concept I am missing here that involves painting components on different panels. Here is what I have in my GamePanel class import java.awt.Dimension; import java.util.Random; import javax.swing.*; public class GamePanel extends JPanel { Random myRand = new Random(); Head head = new Head(20,20,0,0); public GamePanel(){ this.setSize(new Dimension(640, 480)); this.add(head); } } Any suggestions on how to get this to add to the JPanel? Also, is this a good way to go about having the picture float around the screen randomly for a game?

    Read the article

  • php class scope when calling a non-method function not accessing all class members

    - by Aglystas
    So I'm using a stand alone function from within a class that that uses the class it's being called from. Here's the function function catalogProductLink($product_id,$product_name,$categories=true) { //This is the class that the function is called from global $STATE; if ($categories) { //The $STATE->category_id is the property I want to access, which I can't if (is_array($STATE->category_id)) { foreach($STATE->category_id as $cat_id) { if ($cat_id == 0) continue; $str .= "c$cat_id/"; } } } $str .= catalogUrlKeywords($product_name).'-p'.$product_id.'.html'; return $str; } And here's the function call, which is being made from within the $STATE class. $redirect = catalogProductLink($this->product_id, $tempProd->product_name, true, false); The object that I need access to is the $STATE object that has been declared global. Prior to this function call there are lots of public properties populated, but when I look at the $STATE object within the function scope it loses all the properties but one, product_id. The property that matters for this function is the category_id property, which is an array of category id's. I'm wondering why I don't have access to all the public properties of the $STATE object and how I can get access to them.

    Read the article

  • Template Child Class Overriding a Parent Class's Virtual Function

    - by user334066
    The below code compiles with gcc v4.3.3 and the templated child class seems to be overriding a virtual function in the parent, but doesn't that break the rule that you cannot have a virtual template function? Or is something else happening that I don't understand? class BaseClass { public: virtual void Func(int var) { std::cout<<"Base int "<<var<<std::endl; } virtual void Func(double var) { std::cout<<"Base double "<<var<<std::endl; } }; template <class TT> class TemplateClass : public BaseClass { public: using BaseClass::Func; virtual void Func(TT var) { std::cout<<"Child TT "<<var<<std::endl; } }; int main(int argc, char **argv) { BaseClass a; TemplateClass<int> b; BaseClass *c = new TemplateClass<int>; int intVar = 3; double doubleVar = 5.5; a.Func(intVar); a.Func(doubleVar); b.Func(intVar); b.Func(doubleVar); c->Func(intVar); c->Func(doubleVar); delete c; } This then outputs: Base int 3 Base double 5.5 Child TT 3 Base double 5.5 Child TT 3 Base double 5.5 as I hoped, but I'm not sure why it works.

    Read the article

  • PHP class to C# class?

    - by LordSauron
    I work for a company that makes application's in C#. recently we got a customer asking us to look in to rebuilding an application written in PHP. This application receives GPS data from car mounted boxes and processes that into workable information. The manufacturer for the GPS device has a PHP class that parses the received information and extracts coordinates. We were looking in to rewriting the PHP class to a C# class so we can use it and adapt it. And here it comes, on the manufacturers website there is a singel line of text that got my skin krawling: "The encoding format and contents of the transmitted data are subject to constant changes. This is caused by implementations of additional features by new module firmware versions which makes it virtually impossible to document it and for you to properly decode it yourself." So i am now looking for a option to use the "constantly changing" PHP class and access it in C#. Some thing link a shell only exposing some function's i need. Except i have no idea how i can do this. Can any one help me find a solution for this.

    Read the article

  • Accessing derived class members with a base class pointer

    - by LRB
    I am making a simple console game in C++ I would like to know if I can access members from the 'entPlayer' class while using a pointer that is pointing to the base class ( 'Entity' ): class Entity { public: void setId(int id) { Id = id; } int getId() { return Id; } protected: int Id; }; class entPlayer : public Entity { string Name; public: entPlayer() { Name = ""; Id = 0; } void setName(string name) { Name = name; } string getName() { return Name; } }; Entity *createEntity(string Type) { Entity *Ent = NULL; if (Type == "player") { Ent = new entPlayer; } return Ent; } void main() { Entity *ply = createEntity("player"); ply->setName("Test"); ply->setId(1); cout << ply->getName() << endl; cout << ply->getId() << endl; delete ply; } How would I be able to call ply-setName etc? OR If it's not possible that way, what would be a better way?

    Read the article

  • Trouble calling a method from an external class

    - by Bradley Hobbs
    Here is my employee database program: import java.util.*; import java.io.*; import java.io.File; import java.io.FileReader; import java.util.ArrayList; public class P { //Instance Variables private static String empName; private static String wage; private static double wages; private static double salary; private static double numHours; private static double increase; // static ArrayList<String> ARempName = new ArrayList<String>(); // static ArrayList<Double> ARwages = new ArrayList<Double>(); // static ArrayList<Double> ARsalary = new ArrayList<Double>(); static ArrayList<Employee> emp = new ArrayList<Employee>(); public static void main(String[] args) throws Exception { clearScreen(); printMenu(); question(); exit(); } public static void printArrayList(ArrayList<Employee> emp) { for (int i = 0; i < emp.size(); i++){ System.out.println(emp.get(i)); } } public static void clearScreen() { System.out.println("\u001b[H\u001b[2J"); } private static void exit() { System.exit(0); } private static void printMenu() { System.out.println("\t------------------------------------"); System.out.println("\t|Commands: n - New employee |"); System.out.println("\t| c - Compute paychecks |"); System.out.println("\t| r - Raise wages |"); System.out.println("\t| p - Print records |"); System.out.println("\t| d - Download data |"); System.out.println("\t| u - Upload data |"); System.out.println("\t| q - Quit |"); System.out.println("\t------------------------------------"); System.out.println(""); } public static void question() { System.out.print("Enter command: "); Scanner q = new Scanner(System.in); String input = q.nextLine(); input.replaceAll("\\s","").toLowerCase(); boolean valid = (input.equals("n") || input.equals("c") || input.equals("r") || input.equals("p") || input.equals("d") || input.equals("u") || input.equals("q")); if (!valid){ System.out.println("Command was not recognized; please try again."); printMenu(); question(); } else if (input.equals("n")){ System.out.print("Enter the name of new employee: "); Scanner stdin = new Scanner(System.in); empName = stdin.nextLine(); System.out.print("Hourly (h) or salaried (s): "); Scanner stdin2 = new Scanner(System.in); wage = stdin2.nextLine(); wage.replaceAll("\\s","").toLowerCase(); if (!(wage.equals("h") || wage.equals("s"))){ System.out.println("Input was not h or s; please try again"); } else if (wage.equals("h")){ System.out.print("Enter hourly wage: "); Scanner stdin4 = new Scanner(System.in); wages = stdin4.nextDouble(); Employee emp1 = new HourlyEmployee(empName, wages); emp.add(emp1); printMenu(); question();} else if (wage.equals("s")){ System.out.print("Enter annual salary: "); Scanner stdin5 = new Scanner(System.in); salary = stdin5.nextDouble(); Employee emp1 = new SalariedEmployee(empName, salary); printMenu(); question();}} else if (input.equals("c")){ for (int i = 0; i < emp.size(); i++){ System.out.println("Enter number of hours worked by " + emp.get(i) + ":"); } Scanner stdin = new Scanner(System.in); numHours = stdin.nextInt(); System.out.println("Pay: " + emp1.computePay(numHours)); System.out.print("Enter number of hours worked by " + empName); Scanner stdin2 = new Scanner(System.in); numHours = stdin2.nextInt(); System.out.println("Pay: " + emp1.computePay(numHours)); printMenu(); question();} else if (input.equals("r")){ System.out.print("Enter percentage increase: "); Scanner stdin = new Scanner(System.in); increase = stdin.nextDouble(); System.out.println("\nNew Wages"); System.out.println("---------"); // System.out.println(Employee.toString()); printMenu(); question(); } else if (input.equals("p")){ printArrayList(emp); printMenu(); question(); } else if (input.equals("q")){ exit(); } } } Here is one of the class files: public abstract class Employee { private String name; private double wage; protected Employee(String name, double wage){ this.name = name; this.wage = wage; } public String getName() { return name; } public double getWage() { return wage; } public void setName(String name) { this.name = name; } public void setWage(double wage) { this.wage = wage; } public void percent(double wage, double percent) { wage *= percent; } } And here are the errors: P.java:108: cannot find symbol symbol : variable emp1 location: class P System.out.println("Pay: " + emp1.computePay(numHours)); ^ P.java:112: cannot find symbol symbol : variable emp1 location: class P System.out.println("Pay: " + emp1.computePay(numHours)); ^ 2 errors I'm trying to the get paycheck to print out but i'm having trouble with how to call the method. It should take the user inputed numHours and calculate it then print on the paycheck for each employee. Thanks!

    Read the article

  • Serializing a class containing a custom class

    - by Netfangled
    I want to serialize an object as xml that contains other custom classes. From what I understand (I've been reading MSDN and SO mostly), the XmlSerializer doesn't take this into account. This is the line that's confusing me: XML serialization serializes only the public fields and property values of an object into an XML stream. XML serialization does not include type information. For example, if you have a Book object that exists in the Library namespace, there is no guarantee that it will be deserialized into an object of the same type. Taken from MSDN, here For example, I want to serialize an object of type Order, but it contains a list of Products, and each one contains an object of type Category: class Order { List<Product> products; } class Product { Category type; } class Category { string name; string description; } And I want my Order object to be serialized like so: <Order> <Product> <Category Name=""> <Description></Description> </Category> </Product> <Product> <Category Name=""> <Description></Description> </Category> </Product> <Order> Does the XmlSerializer already do this? If not, is there another class that does or do I have to define the serialization process myself?

    Read the article

  • How do I set an Array in one class with another array in another class in Objective-C

    - by Stef
    Hi Guys, I've populated and array with data like this in one class... PowerClass .h NSMutableArray pickerArray; @property (nonatomic, retain) NSMutableArray pickerArray; - PowerClass .m @synthesize pickerArray; @implementation NSMutableArray *array = [[NSArray alloc] initWithObjects:@"stef", @"steve", @"baddamans", @"jonny", nil]; pickerArray = [NSMutableArray arrayWithArray:array]; And I'm trying to set the Array in another class WeekClass .h PowerClass *powerClass; NSMutableArray *pickerData; @property (nonatomic, retain) NSMutableArray pickerData; @property (nonatomic, retain) PowerClass *powerClass; WeekClass .m @implementation pickerData = [NSMutableArray arrayWithArray:powerClass.pickerArray]; I have no errors or warnings. It just crashes. The NSLog says that the powerClass.PickerArray is Null... I don't know why this is... Please help point me in the right direction... Thanx guys Stef :-)

    Read the article

  • Base class for windows service

    - by user187020
    My new project has a design in which there are number windows services for performing different tasks. I have been given a task to create base class from which all of the windows service will inherit. This base class will perform common functions like creating instances of other windows services by iterating through the config file (may be like Activator.CreateInstance), do event logging on onStart, onStop etc. and may contain some more functionality. Before I start developing stuff, wondering if there is any pattern already in place or someone has good understanding of how to implement this kind of functionality. Any help appreciated.

    Read the article

  • Best way to represent Gender in a class library used in multilingual applications

    - by Hauge
    I'm creating class library with some commonly used classes like persons, addresses etc. This library will be used in an multilingual application, and I am looking for the most convenient way to represent a persons gender. Ideally I would like to be able to code like this: Person person = new Person { Gender = Genders.Male, FirstName = "Nice", LastName = "Dude" } if (person.Gender == Genders.Male) Console.WriteLine("person is Male"); Console.WriteLine(person.Gender); //Should output: Male Console.WriteLine(person.Gender.ToString("da-DK")); //Should output the name of the gender in the language provided List<Gender> genders = Genders.GetAll(); foreach(Gender gender in genders) { Console.WriteLine(gender.ToString()); Console.WriteLine(gender.ToString("da-DK")); } What would you do? An enumeration and a specialized Gender class, but what about the localization then? Regards Jesper Hauge

    Read the article

  • Representing Objective C Protocols on UML class diagrams

    - by joec
    How should i correctly reference protocols on a UML class diagram? For example my ListViewController conforms to the UITableViewDataSource and UITableViewDelegate protocols... where do i put the cellForRowAtIndexPath or numberOfRowsInSection methods? ... in ListViewController where they are implemented or in something like this: <<Protocol>> UITableViewDataSource --------------------- --------------------- -numberOfRowsInSection If i did the latter what would be the association between the ListViewController class and the protocol box be? All i have to show is how i hook into Cocoa Touch some how. Thanks.

    Read the article

  • Enumerator Implementation: Use struct or class?

    - by Hosam Aly
    I noticed that List<T> defines its enumerator as a struct, while ArrayList defines its enumerator as a class. What's the difference? If I am to write an enumerator for my class, which one would be preferable? EDIT: My requirements cannot be fulfilled using yield, so I'm implementing an enumerator of my own. That said, I wonder whether it would be better to follow the lines of List<T> and implement it as a struct.

    Read the article

  • Is it legal to stub the #class method of a Mock object when using RSpec in a Ruby on Rails applicati

    - by MiniQuark
    I would like to stub the #class method of a mock object: describe Letter do before(:each) do @john = mock("John") @john.stub!(:id).and_return(5) @john.stub!(:class).and_return(Person) # is this ok? @john.stub!(:name).and_return("John F.") Person.stub!(:find).and_return(@john) end it.should "have a valid #to field" do letter = Letter.create!(:to=>@john, :content => "Hello John") letter.to_type.should == @john.class.name letter.to_id.should == @john.id end [...] end On line 5 of this program, I stub the #class method, in order to allow things like @john.class.name. Is this the right way to go? Will there be any bad side effect? Edit: The Letter class looks like this: class Letter < ActiveRecord::Base belongs_to :to, :polymorphic => true [...] end I wonder whether ActiveRecord gets the :to field's class name with to.class.name or by some other means. Maybe this is what the class_name method is ActiveRecord::Base is for?

    Read the article

  • Classes, constructor and pointer class members

    - by pocoa
    I'm a bit confused about the object references. Please check the examples below: class ListHandler { public: ListHandler(vector<int> &list); private: vector<int> list; } ListHandler::ListHandler(vector<int> &list) { this->list = list; } Here I would be wasting memory right? So the right one would be: class ListHandler { public: ListHandler(vector<int>* list); private: vector<int>* list; } ListHandler::ListHandler(vector<int>* list) { this->list = list; } ListHandler::~ListHandler() { delete list; }

    Read the article

  • Expand a class instance within a class instance in PropertryGrid

    - by Dmi
    In C#, I have a class set up like so: class Page { public class Element { private string test; public string Test { get { return test; } set { test = value; } } } private Element element; public Element PrimaryElement { get { return element; } set { element = value; } } } If I have a PropertyGrid where the select object is an instance of Page, how can I modify Test in its member PrimaryElement from the PropertyGrid? It shows up in grey and is not expandable nor editable.

    Read the article

  • coding an array in a class library and make a call to it C#

    - by eddy
    I'm new to C#, so this may be a basic question. What I need to do is put an array such as the one below in a class library and then make a call to it. So I'd want the aproprate picture to appear via the class and this array. I know there's a much simpler way to make certain pictures appear, but this is a requirement for the project. It's an asp.NET website in C#. string[] PictureArray; PictureArray = new string[3]; PictureArray[0] = "~/pics/grl.jpg"; PictureArray[1] = "~/pics/pop.jpg"; PictureArray[2] = "~/pics/str.jpg"; PictureArray[3] = "~/pics/unk.jpg";

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >