Search Results

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

Page 33/2039 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Policies Array Class-Design wrapper

    - by PT
    Hi, i want to write an wrapper for different Array Classes with different Policies. For example: typedef ArrayType<useValArray,StdAllocator> Array; // one global assignment I want to use the class like a blitz++ Array for example: Array<double,2> x(2,2); //maps the Array to an Valarray or to a Blitz++ Array Array<double,2> x2(5,6); is this Posible? Which technics i need to realise that?

    Read the article

  • returning values from function or method multiple times by only calling the class once

    - by Sokhrat Sikar
    I have a members.php file that shows my websites members. I echo members name by using foreach method. A method of Members class returns an array, then I use foreach loop in the members.php file to echo the members. I am trying to aovid writing php code in my members.php file. Is there a way to avoid using foreach inside members.php file? For example, is it possible to return value from a method couple of times? (by only calling the object once). Just like how we normally call the functions? This question doesn't make sense, but I am just trying to see if there is a away around this issue?

    Read the article

  • Generic collection class?

    - by Mark
    Is there anyway I can do this? class TSOC<TCollection, TValue> : ICollection<TValue>, INotifyCollectionChanged where TCollection : ICollection { private TCollection<TValue> collection; } It doesn't like my definition of collection. I'd prefer the definition to look like TSOC<TCollection> where the user can pass in List<int> or something, but then I need to pull out the "int" to know what interface to implement.

    Read the article

  • class member access specifiers

    - by pdehaan
    I understand what the typical access specifiers are, and what they mean. 'public' members are accessible anywhere, 'private' members are accessible only by the same class and friends, etc. What I'm wondering is what, if anything, this equates to in lower-level terms. Are their any post-compilation functional differences between these beyond the high-level restrictions (what can access what) imposed by the language (c++ in this case) they're used in. Another way to put it - if this were a perfect world where programmers always made good choices (like not accessing members that may change later and using only well defined members that should stay the same between implementations), would their be any reason to use these things?

    Read the article

  • Why is this class library dll not getting information from app.config

    - by baron
    I am developing a custom HttpHandler, to do so I write a C# Class Library and compile to DLL. As part of this I have some directory locations which I want not hard coded in the app, so i'm trying to put it in the app.config which I've used before. Before this has worked by just going building the app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Share" value="C:\...\"/> </appSettings> </configuration> And then obtaining this in code like: var shareDirectory = ConfigurationManager.AppSettings["Share"]; But when I compile it and put it in the bin folder for the webservice, it keeps getting null for shareDirectory, probably because it can't find app.config. So how do I make sure this is included so I don't have to hard code my direcotry locations? I notice it will essentially after compiled we get the assembly.dll and the assembly.dll.config which is the app.config file, so it's definetly there in the bin folder!

    Read the article

  • Perl OO frameworks and program design - Moose and Conway's inside-out objects (Class::Std)

    - by Emmel
    This is more of a use-case type of question... but also generic enough to be more broadly applicable: In short, I'm working on a module that's more or less a command-line wrapper; OO naturally. Without going into too many details (unless someone wants them), there isn't a crazy amount of complexity to the system, but it did feel natural to have three or four objects in this framework. Finally, it's an open source thing I'll put out there, rather than a module with a few developers in the same firm working on it. First I implemented the OO using Class::Std, because Perl Best Practices (Conway, 2005) made a good argument for why to use inside-out objects. Full control over what attributes get accessed and so on, proper encapsulation, etc. Also his design is surprisingly simple and clever. I liked it, but then noticed that no one really uses this; in fact it seems Conway himself doesn't really recommend this anymore? So I moved to everyone's favorite, Moose. It's easy to use, although way way overkill feature-wise for what I want to do. The big, major downside is: it's got a slew of module dependencies that force users of my module to download them all. A minor downside is it's got way more functionality than I really need. What are recommendations? Inconvenience fellow developers by forcing them to use a possibly-obsolete module, or force every user of the module to download Moose and all its dependencies? Is there a third option for a proper Perl OO framework that's popular but neither of these two?

    Read the article

  • javascript class calling XMLHttpRequest internally, then handling onreadystatechange

    - by Radu M
    this thing almost works: function myClass(url) { this.source = url; this.rq = null; this.someOtherProperty = "hello"; // open connection to the ajax server this.start = function() { if (window.XMLHttpRequest) { this.rq = new XMLHttpRequest(); if (this.rq.overrideMimeType) this.rq.overrideMimeType("text/xml"); } else this.rq = new ActiveXObject("Microsoft.XMLHTTP"); try { this.rq.onreadystatechange = connectionEvent; this.rq.open("GET", this.source, true); this.rq.send(null); this.state = 1; } catch (err) { // some error handler here } } function connectionEvent() { alert("i'm here"); alert("this doesnt work: " + this.someOtherProperty); } } // myClass so it's nothing more than having the XMLHttpRequest object as a member of my class, instead of globally defined, and invoking it in the traditional way. however, inside my connectionEvent callback function, the meaning of "this" is lost, even though the function itself is scoped inside myClass. i also made sure that the object that i instantiate from myClass is kept alive long enough (declared global in the script). in all the examples of using javascript classes that i saw, "this" was still available inside the inner functions. for me, it is not, even if i take my function outside and make it a myClass.prototype.connectionEvent. what am i doing wrong? thank you.

    Read the article

  • Cannot create instance of abstract class

    - by SmartestVEGA
    I am trying to compile the following code and i am getting the error: Cannot create instance of abstract class . Please help m_objExcel = new Excel.Application(); m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks; m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt)); m_objSheets = (Excel.Sheets)m_objBook.Worksheets; m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1)); // Create an array for the headers and add it to cells A1:C1. object[] objHeaders = {"Order ID", "Amount", "Tax"}; m_objRange = m_objSheet.get_Range("A1", "C1"); m_objRange.Value = objHeaders; m_objFont = m_objRange.Font; m_objFont.Bold=true; // Create an array with 3 columns and 100 rows and add it to // the worksheet starting at cell A2. object[,] objData = new Object[100,3]; Random rdm = new Random((int)DateTime.Now.Ticks); double nOrderAmt, nTax; for(int r=0;r<100;r++) { objData[r,0] = "ORD" + r.ToString("0000"); nOrderAmt = rdm.Next(1000); objData[r,1] = nOrderAmt.ToString("c"); nTax = nOrderAmt*0.07; objData[r,2] = nTax.ToString("c"); } m_objRange = m_objSheet.get_Range("A2", m_objOpt); m_objRange = m_objRange.get_Resize(100,3); m_objRange.Value = objData; // Save the Workbook and quit Excel. m_objBook.SaveAs(m_strSampleFolder + "Book2.xls", m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange, m_objOpt, m_objOpt, m_objOpt, m_objOpt); m_objBook.Close(false, m_objOpt, m_objOpt); m_objExcel.Quit();

    Read the article

  • How to propagate .java file change to .class under eclipse, tomcat & stripes

    - by BigBourin
    Hi, i'm new to java and i got some problems. i'm developping a web application using the framework stripes on tomcat 6.0. I'm working with eclipse EE on windows. i successfully managed to get the stripes example application (called Bugzooky) up and running on my tomcat server. I imported the .war file and stripes libs in Eclipse. Here is the stripes archive containing the examples and libs But now i'm trying to change the example source files to learn how does it work. but whatever the modification made to the source files "WebContent/WEB-INF/src/*.java", nothing change! even after restarting the server. i noticed that the classes are compiled into .class files in the "ImportedClasses" folder, and tomcat always use these files, they are never updated, and if i removed one of them, the application just don't start. it look like my source files don't exists! I also tried to build my webapp from scratch, but when i tried to use the features used in the example files (like SecurityFilter.java): import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import ... It ends up with plenty of: the import javax.servlet.Filter cannot be resolved I checked the Librairies and it look like i'm using exactly the same as the example. It's probably something i didn't understood about java but i googled 100 times yesterday, and i can't find the solution (i probably didn't search the right place because i don't really understand my problem). I hope you'll be able to help me.

    Read the article

  • Dynamic Connection Strings for Strongly Typed DataSet in a Class Library using App.Config

    - by Luc
    This is my first question on StackOverflow.com and I'm not sure if this is the correct way to do this. I found a similar question titled: Modifying the Data Source for the Strongly Typed Dataset Connection String. However, the answer provided is not working for me. I'm not able to comment on it because I don't have enough "reputation points" (again, I just signed up), and I didn't want to provide an "answer", because I don't know the correct answer. My problem is that I need to be able to modify the connection string inside the generated myproject.dll.config file, but doing so has no effect for me at all. My library still uses the default connection string that was setup at design time. I've tried everything I know to try, but still no luck. I've tried working around the issue using multiple different approaches, but still the problem persists. I can't find any help on the internet with my specific problem either. It would be great if somebody could shed some light as to why my modified config file isn't being read. Useful information: I'm using a Strongly Typed DataSet I don't know the actual connection string at design time. The app.config doesn't allow me to specify a 'User' scoped connection string. I'm tied to a class library (no Windows Forms) Thank you for any help! Luc

    Read the article

  • C# class design - expose variables for reading but not setting

    - by James Brauman
    I have a a polygon class which stores a list of Microsoft.Xna.Framework.Vector2 as the vertices of the polygon. Once the polygon is created, I'd like other classes to be able to read the position of the vertices, but not change them. I am currently exposing the vertices through this field: /// <summary> /// Gets the vertices stored for this polygon. /// </summary> public List<Vector2> Vertices { get { return _vertices; } } List<Vector2> _vertices; However you can change any vertex using code like: Polygon1.Vertices[0] = new Vector2(0, 0); or Polygon1.Vertices[0].X = 0; How can I limit other classes to be able to only read the properties of these vertices, and not be able to set a new one to my List? The only thing I can think of is to pass a copy to classes that request it. Note that Vector2 is a struct that is part of the XNA framework and I cannot change it. Thanks.

    Read the article

  • sorting a gridview in class

    - by user175084
    ok i have a project which has many gridview in its pages... now i am sorting the fridveiw using the sorting function like this: protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { DataTable dt = Session["TaskTable2"] as DataTable; if (dt != null) { //Sort the data. dt.DefaultView.Sort = e.SortExpression + " " + GetSortDirection(e.SortExpression); GridView1.DataSource = Session["TaskTable2"]; GridView1.DataBind(); } } private string GetSortDirection(string column) { // By default, set the sort direction to ascending. string sortDirection2 = "ASC"; // Retrieve the last column that was sorted. string sortExpression2 = ViewState["SortExpression2"] as string; if (sortExpression2 != null) { // Check if the same column is being sorted. // Otherwise, the default value can be returned. if (sortExpression2 == column) { string lastDirection = ViewState["SortDirection2"] as string; if ((lastDirection != null) && (lastDirection == "ASC")) { sortDirection2 = "DESC"; } } } // Save new values in ViewState. ViewState["SortDirection2"] = sortDirection2; ViewState["SortExpression2"] = column; return sortDirection2; } but this code is being repeated in many pages so i tried to put this function in a C# class and try to call it but i get errors.... for starters i get the viewstate error saying :| "viewstate does not exist in the current context" so how do i go about doing this ....?? thanks

    Read the article

  • targeting sprites from a method in the document class - null object reference

    - by Freddyk
    Hi I am trying to code a flash app entirely in the document class. I am using GestureWorks with a touch screen. When a user essentially presses a button it calls a method that should hide a specific graphic but not the graphic they touched. Essentially I need a way to refer to a graphic on the screen using a method besides 'e.target'. //This code works because it can access 'e.target'. private function photo1SpriteFlickHandler(e:GestureEvent):void { var openTween:Tween = new Tween(e.target, "x", Strong.easeOut, 232, 970, 5, true); } //this code gives me a null object reference because I am using 'photo1Sprite' rather than 'e.target' private function photo1SpriteFlickHandler(e:GestureEvent):void { var openTween:Tween = new Tween(photo1Sprite, "x", Strong.easeOut, 232, 970, 5, true); } //photo1Sprite has already been programatically added to the screen as so: var photo1Sprite = new TouchSprite(); var photo1Loader=new Loader(); photo1Loader.load(new URLRequest("media/photos1/photo1.jpg")); photo1Loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaderComplete); photo1Sprite.x = 232; photo1Sprite.y = 538; photo1Sprite.scaleX = .3; photo1Sprite.scaleY = .3; photo1Sprite.blobContainerEnabled = true; photo1Sprite.addEventListener(TouchEvent.TOUCH_DOWN, startDrag_Press); photo1Sprite.addEventListener(TouchEvent.TOUCH_UP, stopDrag_Release); photo1Sprite.addChild(photo1Loader); addChild(photo1Sprite); So I can make photo1Sprite react if my method is attached to it directly using 'e.target' but not if I am trying to call it from a method that was called from another element on the screen.

    Read the article

  • Issue with class design to model user preferences for different classes

    - by Mulone
    Hi all, I'm not sure how to design a couple of classes in my app. Basically that's a situation: each user can have many preferences each preference can be referred to an object of different classes (e.g. album, film, book etc) the preference is expressed as a set of values (e.g. score, etc). The problem is that many users can have preferences on the same objects, e.g.: John: score=5 for filmid=apocalypsenow Paul: score=3 for filmid=apocalypsenow And naturally I don't want to duplicate the object film in each user. So I could create a class called "preference" holding a score and then a target object, something like: User{ hasMany preferences } Preference{ belongsTo User double score Film target Album target //etc } and then define just one target. Then I would create an interface for the target Classes (album, film etc): Interface canBePreferred{ hasMany preferences } And implement all of those classes. This could work, but it looks pretty ugly and it would requires a lot of joins to work. Do you have some patterns I could use to model this nicely? Cheers, Mulone

    Read the article

  • Class lookup structure array in C++

    - by wyatt
    I'm trying to create a structure array which links input strings to classes as follows: struct {string command; CommandPath cPath;} cPathLookup[] = { {"set an alarm", AlarmCommandPath}, {"send an email", EmailCommandPath}, {"", NULL} }; which will be used as follows: CommandPath *cPath = NULL; string input; getline(cin, input); for(int i = 0; cPathLookup[i] != ""; i++) { if(cPathLookup[i].command == input) cPath = new cPathLookup[i].cPath; } Obviously, this code is meaningless, but I think my intention is apparent - depending on input, I'd like cPath to be initialized as either a new AlarmCommandPath or a new EmailCommandPath. I could handle it with a function returning an instance depending on input, but a whole sequence of ifs just seems inelegant. I should also note that, in case it's not apparent and important, that AlarmCommandPath and EmailCommandPath are derived from CommandPath, and CommandPath is an abstract class. Thanks for any help you can offer. EDIT: I just noticed that, in spite of CommandPath being abstract, I have a declaration: CommandPath *cPath = NULL; in working code. Why does that compile?

    Read the article

  • I cant put a string in a switch nor an array in a class

    - by TimothyTech
    Okay, im making a pretty big file in my opinion, so i wanted to separate it into several files for cleaner code. so i have my main .cpp file and two header files holding my classes. well the header files dont hold strings, it aboslutely wont budge. i call the library in both my .cpp file and even tried it in my header file. another issue i ran into is using strings to make switches function, reason being if i use integers in a switch if the user inputs a alphabetical character the program goes into an endless loop. string choice; switch (choice) { case "1" : //... break; case "2" : //... break; } and my last issue is when i create an object in a case it gives an error. says cross initialization of object. string choice; switch (choice) { case "1" : Class object; break; case "2" : //... break; }

    Read the article

  • Dynamically Changing the Display Names of Menus and Popups

    - by Geertjan
    Very interesting thing and handy to know when needed is the fact that "menuText" and "popupText" (from org.openide.awt.ActionRegistration) can be changed dynamically, via "putValue" as shown below for "popupText". The Action class, in this case, needs to be eager, hence you won't receive the object of interest via the constructor, but you can easily use the global Lookup for that purpose instead, as also shown below. import java.awt.event.ActionEvent; import java.text.DateFormat; import java.text.SimpleDateFormat; import javax.swing.AbstractAction; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectUtils; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; import org.openide.util.Utilities; @ActionID( category = "Project", id = "org.ptt.DemoProjectAction") @ActionRegistration( lazy = false, displayName = "NOT-USED") @ActionReference(path = "Projects/Actions", position = 0) public final class DemoProjectAction extends AbstractAction{ private final ProjectInformation context; public DemoProjectAction() { putValue("popupText", "Select Me To See Current Time!"); context = ProjectUtils.getInformation( Utilities.actionsGlobalContext().lookup(Project.class)); } @Override public void actionPerformed(ActionEvent e) { refresh(); } protected void refresh() { DateFormat formatter = new SimpleDateFormat("HH:mm:ss"); String formatted = formatter.format(System.currentTimeMillis()); putValue("popupText", "Time: " + formatted + " (" + context.getDisplayName() +")"); } } Now, let's do something semi useful and display, in the popup, which is available when you right-click a project, the time since the last change was made anywhere in the project, i.e., we can listen recursively to any changes done within a project and then update the popup with the newly acquired information, dynamically: import java.awt.event.ActionEvent; import java.text.DateFormat; import java.text.SimpleDateFormat; import javax.swing.AbstractAction; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectUtils; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; import org.openide.filesystems.FileAttributeEvent; import org.openide.filesystems.FileChangeListener; import org.openide.filesystems.FileEvent; import org.openide.filesystems.FileRenameEvent; import org.openide.util.Utilities; @ActionID( category = "Project", id = "org.ptt.TrackProjectTimerAction") @ActionRegistration( lazy = false, displayName = "NOT-USED") @ActionReference( path = "Projects/Actions", position = 0) public final class TrackProjectTimerAction extends AbstractAction implements FileChangeListener { private final Project context; private Long startTime; private Long changedTime; private DateFormat formatter; public TrackProjectTimerAction() { putValue("popupText", "Enable project time tracker"); this.formatter = new SimpleDateFormat("HH:mm:ss"); context = Utilities.actionsGlobalContext().lookup(Project.class); context.getProjectDirectory().addRecursiveListener(this); } @Override public void actionPerformed(ActionEvent e) { startTimer(); } protected void startTimer() { startTime = System.currentTimeMillis(); String formattedStartTime = formatter.format(startTime); putValue("popupText", "Timer started: " + formattedStartTime + " (" + ProjectUtils.getInformation(context).getDisplayName() + ")"); } @Override public void fileChanged(FileEvent fe) { changedTime = System.currentTimeMillis(); formatter = new SimpleDateFormat("mm:ss"); String formattedLapse = formatter.format(changedTime - startTime); putValue("popupText", "Time since last change: " + formattedLapse + " (" + ProjectUtils.getInformation(context).getDisplayName() + ")"); startTime = changedTime; } @Override public void fileFolderCreated(FileEvent fe) {} @Override public void fileDataCreated(FileEvent fe) {} @Override public void fileDeleted(FileEvent fe) {} @Override public void fileRenamed(FileRenameEvent fre) {} @Override public void fileAttributeChanged(FileAttributeEvent fae) {} }

    Read the article

  • Defining a Class in Objective C, XCode

    - by Brett
    Hello; I am new to Objective C, and am trying to write a class that defines a complex number. The code seems fine but when I print to the console, my values for instance variables are 0. Here is the code: // // ComplexNumber.h // Mandelbrot Set // // Created by Brett on 10-06-02. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import <stdio.h> @interface ComplexNumber : NSObject { double real; double imaginary; } // Getters -(double) real; -(double) imaginary; // Setters -(void)setReal: (double) a andImaginary: (double) b; //Function -(ComplexNumber *)squared; @end // // ComplexNumber.m // Mandelbrot Set // // Created by Brett on 10-06-02. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "ComplexNumber.h" #import <math.h> #import <stdio.h> @implementation ComplexNumber -(double)real{ return self->real; } -(double)imaginary{ return self->imaginary; } -(void)setReal: (double) a andImaginary: (double) b{ self->real=a; self->imaginary=b; } -(ComplexNumber *)squared{ double a = pow(real,2); double b = pow(imaginary, 2); double c = 2*real*imaginary; ComplexNumber *d; [d setReal:(a-b) andImaginary: c]; return d; } @end In the App Delegate for debugging purposes I added: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ComplexNumber *testNumber = [[ComplexNumber alloc] init]; [testNumber setReal:55.0 andImaginary:30.0]; NSLog(@"%d", testNumber.real); // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } But the console returns 0 everytime. Help?

    Read the article

  • How do I create a class in Javascript?

    - by William
    This is what I got so far, and it's not working at all :( <!DOCTYPE html> <html lang="en"> <head> <title>Class Test</title> <meta charset="utf-8" /> <style> body { text-align: center; background-color: #ffffff;} #box { position: absolute; left: 610px; top: 80px; height: 50px; width: 50px; background-color: #ff0000; color: #000000;} </style> <script type="text/javascript"> document.onkeydown=function(event){keyDown(event)}; document.onkeyup=function(event){keyUp(event)}; var box = 0; function Player () { var speed = 5; var x = 50; var y = 50; } function update() { box.style.left = this.x + "px"; box.style.top = this.y + "px"; box.innerHTML = "<h6 style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;\">X: "+ this.x + "<br /> Y: " + this.y + "</h6>"; } var player = new Player(); var keys = new Array(256); var i = 0; for (i = 0;i <= 256; i++){ keys[i] = false; } function keyDown(event){ keys[event.keyCode] = true; } function keyUp(event){ keys[event.keyCode] = false; } function update(){ if(keys[37]) player.x -= player.speed; if(keys[39]) player.x += player.speed; player.update(); } setInterval(update, 1000/60); </script> </head> <body> <div id="box" ></div> <script type="text/javascript"> box = document.getElementById('box'); box.innerHTML = "<h6 style=\"margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;\">X: "+ player.x + "<br /> Y: " + player.y + "</h6>"; </script> </body> </html>

    Read the article

  • Cutting down repeating code in c# Class

    - by Tom Gullen
    This is a wrapper for an API I'm working on, am I doing it sort of right? I'm not particularly fond of all the repeating code in the constructor, if someone can show me if I can reduce that it would be very helpful! public class WebWizForumVersion { // Properties of returned data public string Software { get; private set; } public string Version { get; private set; } public string APIVersion { get; private set; } public string Copyright { get; private set; } public string BoardName { get; private set; } public string URL { get; private set; } public string Email { get; private set; } public string Database { get; private set; } public string InstallationID { get; private set; } public bool NewsPad { get; private set; } public string NewsPadURL { get; private set; } public WebWizForumVersion(XmlReader Data) { try { Data.ReadToFollowing("Software"); this.Software = Data.ReadElementContentAsString(); Data.ReadToFollowing("Version"); this.Version = Data.ReadElementContentAsString(); Data.ReadToFollowing("ApiVersion"); this.APIVersion = Data.ReadElementContentAsString(); Data.ReadToFollowing("Copyright"); this.Copyright = Data.ReadElementContentAsString(); Data.ReadToFollowing("BoardName"); this.BoardName = Data.ReadElementContentAsString(); Data.ReadToFollowing("URL"); this.URL = Data.ReadElementContentAsString(); Data.ReadToFollowing("Email"); this.Email = Data.ReadElementContentAsString(); Data.ReadToFollowing("Database"); this.Database = Data.ReadElementContentAsString(); Data.ReadToFollowing("InstallID"); this.InstallationID = Data.ReadElementContentAsString(); Data.ReadToFollowing("NewsPad"); this.NewsPad = bool.Parse(Data.ReadElementContentAsString()); Data.ReadToFollowing("NewsPadURL"); this.NewsPadURL = Data.ReadElementContentAsString(); } catch (Exception e) { } } }

    Read the article

  • Super class variables not printing through sub class

    - by Abhishek Singh
    Can u tell me why this code is not displaying any result on the console. class employee { protected String name; protected double salary; protected String dob; public employee(String name, double salary, String dob) { this.name = name; this.salary = salary; this.dob = dob; } public employee(String name, double salary) { this.name = name; this.salary = salary; } } public class Manage extends employee { String dept1; public Manage(String name, double salary, String dob, String dept1) { super(name, salary, dob); this.dept1 = dept1; } public Manage(String name, double salary, String dept1) { super(name, salary); this.dept1 = dept1; } public static void main(String args[]) { employee e = new employee("Vikas", 122345); employee e2 = new employee("Vikas", 122345, "12-2-1991"); Manage m = (Manage) new Manage("Vikas", 122345, "Sales"); Manage m2 = new Manage("Vikas", 122345, "12-2-1991", "sales"); m.display(); m2.display(); } public void display() { System.out.println("Name " + name); System.out.println("Salary " + salary); System.out.println("Birth " + dob); System.out.println("Department " + dept1); } }

    Read the article

  • How to achieve interaction between GUI class with logic class

    - by volting
    Im new to GUI programming, and haven't done much OOP. Im working on a basic calculator app to help me learn GUI design and to brush up on OOP. I understand that anything GUI related should be kept seperate from the logic, but Im unsure how to implement interaction between logic an GUI classes when needed i.e. basically passing variables back and forth... Im using TKinter and when I pass a tkinter variable to my logic it only seems to hold the string PY_VAR0. def on_equal_btn_click(self): self.entryVariable.set(self.entryVariable.get() + "=") calculator = Calc(self.entryVariable) self.entryVariable.set(calculator.calculate()) Im sure that im probably doing something fundamentally wrong and probabaly really stupid, I spent a considerable amount of time experimenting (and searching for answers online) but Im getting no where. Any help would be appreciated. Thanks, V The Full Program (well just enough to show the structure..) import Tkinter class Gui(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() self.create_widgets() """ grid config """ #self.grid_columnconfigure(0,weight=1,pad=0) self.resizable(False, False) def create_widgets(self): """row 0 of grid""" """Create Text Entry Box""" self.entryVariable = Tkinter.StringVar() self.entry = Tkinter.Entry(self,width=30,textvariable=self.entryVariable) self.entry.grid(column=0,row=0, columnspan = 3 ) self.entry.bind("<Return>", self.on_press_enter) """create equal button""" equal_btn = Tkinter.Button(self,text="=",width=4,command=self.on_equal_btn_click) equal_btn.grid(column=3, row=0) """row 1 of grid""" """create number 1 button""" number1_btn = Tkinter.Button(self,text="1",width=8,command=self.on_number1_btn_click) number1_btn.grid(column=0, row=1) . . . def on_equal_btn_click(self): self.entryVariable.set(self.entryVariable.get() + "=") calculator = Calc(self.entryVariable) self.entryVariable.set(calculator.calculate()) class Calc(): def __init__(self, equation): self.equation = equation def calculate(self): #TODO: parse string and calculate... return self.equation if __name__ == "__main__": app = Gui(None) app.title('Calculator') app.mainloop()

    Read the article

  • Cast base class object to derived class

    - by Popgalop
    Lets say I have two classes, animal and dog like this. class Animal { }; class Dog : public Animal { }; And I have an animal object named animal, that is actually an instance of dog, how would I cast it back to dog? This may seem like an odd question, but I need it because I am writing a programming language interpreter, and on the stack everything is stored as a BaseObject, and all the other datatypes extend BaseObject. How would I cast the base object from the stack, to a specific data type? I have tried something like this Dog dog = static_cast<Dog>(animal); But it gives me an error 1>------ Build started: Project: StackTests, Configuration: Debug Win32 ------ 1> StackTests.cpp 1>c:\users\owner\documents\visual studio 2012\projects\stacktests\stacktests\stacktests.cpp(173): error C2440: 'static_cast' : cannot convert from 'Animal' to 'Dog' 1> No constructor could take the source type, or constructor overload resolution was ambiguous 1>c:\users\owner\documents\visual studio 2012\projects\stacktests\stacktests\stacktests.cpp(173): error C2512: 'Dog' : no appropriate default constructor available ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Read the article

  • Identifying a class which is extending an abstract class

    - by Simon A. Eugster
    Good Evening, I'm doing a major refactoring of http://wiki2xhtml.sourceforge.net/ to finally get better overview and maintainability. (I started the project when I decided to start programming, so – you get it, right? ;)) At the moment I wonder how to solve the problem I'll describe now: Every file will be put through several parsers (like one for links, one for tables, one for images, etc.): public class WikiLinks extends WikiTask { ... } public class WikiTables extends WikiTask { ... } The files will then be parsed about this way: public void parse() { if (!parse) return; WikiTask task = new WikiLinks(); do { task.parse(this); } while ((task = task.nextTask()) != null); } Sometimes I may want to use no parser at all (for files that only need to be copied), or only a chosen one (e.g. for testing purposes). So before running task.parse() I need to check whether this certain parser is actually necessary/desired. (Perhaps via Blacklist or Whitelist.) What would you suggest for comparing? An ID for each WikiTask (how to do?)? Comparing the task Object itself against a new instance of a WikiTask (overhead)?

    Read the article

  • Calling a class method within a method definition in the same class

    - by user1786288
    So I'm writing a program for an intro Java class. I'm defining a method to add two fractions together within the class Fraction. Fraction has 2 variables, numerator and denominator. Each of these variables has a setter and a getter. Anyway, I have a problem with my addition method, which is shown below. I've just sort of tried to implement it in a way that made sense, but I'm sure I did something with calling methods/using objects that doesn't work. public void add(Fraction fraction1, Fraction fraction2) { Fraction fraction3 = new Fraction(); int a = fraction1.getNumerator; int b = fraction1.getDenominator; int c = fraction2.getNumerator; int d = fraction2.getDenominator; fraction3.setNumerator((a * d) + (b * c)); fraction3.setDenominator(b * d); } I don't know if the problem is in the method definition, if I can use the object type that way, or if there's something else wrong. any help would be appreciated, and if I need to provide any information, I'll do so ASAP.

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >