Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 38/391 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • Suggest the way to design several classes

    - by Oleg Tarasenko
    Hi, I'm building simple application on as3. Kind of starship game. What I want to do is to create several different star ships. Each one should have different images (different look), different sets of animation (e.g. when it's flying, burning, damaged), different kind of weapon and also different controllers (e.g. one can be managed by user, another one by computer, and I want to be able to reuse same ships for AI controller as well as for users controls). Each ship is created in the following way: Create entity Add spatial Add renderers Add other components.... ...... n. init the ship So what I am trying to do: 1) Create StarShip superclass, to store HP (as every ship has it), store spatial (same reason) 2) Create inherited class for any other ship... (It will contain renderer - (responsible for display part), weapon, set of animations), etc What do you think about such way of composition? Maybe it's better to place everything in super class, and then just create instances using long, long, long constructors like: StarShip(hp:HP, animations:DICT, weapon:Weapon, ....) Need advice

    Read the article

  • referencing ints from other classes

    - by user357032
    if i wanted to reference an int from another class how would i go about doing that??? public class Zoom extends View { private Drawable image; public int zoomControler=20; public Zoom(Context context) { super(context); image=context.getResources().getDrawable(R.drawable.icon); setFocusable(true); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler); image.draw(canvas); } } class HelloOnTouchListener implements OnTouchListener{ @Override public boolean onTouch(View arg0, MotionEvent arg1) { return true; } } in this case i want to reference the zoomControler from the first class in the second helloontouchlistener class

    Read the article

  • Eclipse Javadoc tooltip help doesn't show classes' supertypes and interfaces

    - by Pooria
    I'm talking about the tooltip that pops up when you hover your mouse over a class in your source (which also helps with intellisense and auto completion), which describes what a class/method/etc does. I find it very annoying that it doesn't show what superclass the class (being described) extends or what interfaces it implements. Is there a way to make eclipse show the additional information?

    Read the article

  • Lua class instance with nested tables

    - by Anonnobody
    Hello, Simple lua game with simple class like so: creature = class({ name = "MONSTER BADDY!", stats = { power = 10, agility = 10, endurance = 10, filters = {} }, other_things = ... }) creatureA = creature.new() creatureB = creature.new() creatureA.name = "Frank" creatureB.name = "Zappa" creatureA.stats.agility = 20 creatureB.stats.power = 12 -- blah blah blah Non table values are individual to each instance, but table values are shared among all instances and if I modify a stats.X value in one instance, all other instances see the same stats table. Q1: Is my OO implementation flawed? I tried LOOP and the same result occured, is there a fundamental flaw in my logic? Q2: How would you have each instance of creature have it's own stats table (and sub tables)? PS. I cannot flatten my class table as it's a bit more complicated than the example and other parts of the code are simplified with this nested table implementation. Thanks a bunch.

    Read the article

  • MySQL access classes in PHP

    - by Mike
    I have a connection class for MySQL that looks like this: class MySQLConnect { private $connection; private static $instances = 0; function __construct() { if(MySQLConnect::$instances == 0) { //Connect to MySQL server $this->connection = mysql_connect(MySQLConfig::HOST, MySQLConfig::USER, MySQLConfig::PASS) or die("Error: Unable to connect to the MySQL Server."); MySQLConnect::$instances = 1; } else { $msg = "Close the existing instance of the MySQLConnector class."; die($msg); } } public function singleQuery($query, $databasename) { mysql_select_db(MySQLConfig::DB, $this->connection) or die("Error: Could not select database " . MySQLConfig::DB . " from the server."); $result = mysql_query($query) or die('Query failed.'); return $result; } public function createResultSet($query, $databasename) { $rs = new MySQLResultSet($query, MySQLConfig::DB, $this->connection ) ; return $rs; } public function close() { MySQLConnect::$instances = 0; if(isset($this->connection) ) { mysql_close($this->connection) ; unset($this->connection) ; } } public function __destruct() { $this->close(); } } The MySQLResultSet class looks like this: class MySQLResultSet implements Iterator { private $query; private $databasename; private $connection; private $result; private $currentRow; private $key = 0; private $valid; public function __construct($query, $databasename, $connection) { $this->query = $query; //Select the database $selectedDatabase = mysql_select_db($databasename, $connection) or die("Error: Could not select database " . $this->dbname . " from the server."); $this->result = mysql_query($this->query) or die('Query failed.'); $this->rewind(); } public function getResult() { return $this->result; } // public function getRow() // { // return mysql_fetch_row($this->result); // } public function getNumberRows() { return mysql_num_rows($this->result); } //current() returns the current row public function current() { return $this->currentRow; } //key() returns the current index public function key() { return $this->key; } //next() moves forward one index public function next() { if($this->currentRow = mysql_fetch_array($this->result) ) { $this->valid = true; $this->key++; }else{ $this->valid = false; } } //rewind() moves to the starting index public function rewind() { $this->key = 0; if(mysql_num_rows($this->result) > 0) { if(mysql_data_seek($this->result, 0) ) { $this->valid = true; $this->key = 0; $this->currentRow = mysql_fetch_array($this->result); } } else { $this->valid = false; } } //valid returns 1 if the current position is a valid array index //and 0 if it is not valid public function valid() { return $this->valid; } } The following class is an example of how I am accessing the database: class ImageCount { public function getCount() { $mysqlConnector = new MySQLConnect(); $query = "SELECT * FROM images;"; $resultSet = $mysqlConnector->createResultSet($query, MySQLConfig::DB); $mysqlConnector->close(); return $resultSet->getNumberRows(); } } I use the ImageCount class like this: if(!ImageCount::getCount()) { //Do something } Question: Is this an okay way to access the database? Could anybody recommend an alternative method if it is bad? Thank-you.

    Read the article

  • C# two classes with static members referring to each other

    - by Jerry
    Hi, I wonder why this code doesn't end up in endless recursion. I guess it's connected to the automatic initialization of static members to default values, but can someone tell me "step by step" how does 'a' get the value of 2 and 'b' of 1? public class A { public static int a = B.b + 1; } public class B { public static int b = A.a + 1; } static void Main(string[] args) { Console.WriteLine("A.a={0}, B.b={1}", A.a, B.b); //A.a=2, B.b=1 Console.Read(); }

    Read the article

  • About local Final varibles in java

    - by Sathish
    In java Program, parameters which is defined as String in method declaration.But in method definition it is accessed as final String variable. Whether it'll lead to some issues (like security, memory problem)? For Example: Method Declaration join(String a,String b); Method definition public void join(final String a,final String b) { Authenticator au = new Authenticator(){ public PasswordAuthentication getPasswordAuthentication(){ return new PasswordAuthentication(a,b)} }; } Please help for me and clarify my doubts. Thanks in advance P.S. I;m accessing a and b as final variable because i've to use it in the inner class.

    Read the article

  • Link objects as fields in UML diagram

    - by fearofawhackplanet
    I'm trying to generate a diagram for a design document. I've generated a class diagram in VS. At the moment it's just a bunch of unconnected boxes as there isn't any inheritance going on. It feels like it would be more useful if I could show how the objects interact through properties and parameters. As an example, a Boy class has a method Kiss which takes a Girl object. How can I show that Boy and Girl interact by connecting this in the diagram? Is there a notation for this in UML? Or is there another type of diagram that shows this? Can I make VS draw this connection for me somehow? Or is this a silly/useless idea? It just doesn't feel like a proper diagram unless it's got some lines on it somewhere :)

    Read the article

  • Inheritance classes in Scheme

    - by DreamWalker
    Now I research OOP-part of Scheme. I can define class in Scheme like this: (define (create-queue) (let ((mpty #t) (the-list '())) (define (enque value) (set! the-list (append the-list (list value))) (set! mpty #f) the-list) (define (deque) (set! the-list (cdr the-list)) (if (= (length the-list) 0) (set! mpty #t)) the-list) (define (isEmpty) mpty) (define (ptl) the-list) (define (dispatch method) (cond ((eq? method 'enque) enque) ((eq? method 'deque) deque) ((eq? method 'isEmpty) isEmpty) ((eq? method 'print) ptl))) dispatch)) (Example from css.freetonik.com) Can I implement class inheritance in Scheme?

    Read the article

  • C# creating a Class, having objects as member variables? I think the objects are garbage collecte

    - by Bryan
    So I have a class that has the following member variables. I have get and set functions for every piece of data in this class. public class NavigationMesh { public Vector3 node; int weight; bool isWall; bool hasTreasure; public NavigationMesh(int x, int y, int z, bool setWall, bool setTreasure) { //default constructor //Console.WriteLine(x + " " + y + " " + z); node = new Vector3(x, y, z); //Console.WriteLine(node.X + " " + node.Y + " " + node.Z); isWall = setWall; hasTreasure = setTreasure; weight = 1; }// end constructor public float getX() { Console.WriteLine(node.X); return node.X; } public float getY() { Console.WriteLine(node.Y); return node.Y; } public float getZ() { Console.WriteLine(node.Z); return node.Z; } public bool getWall() { return isWall; } public void setWall(bool item) { isWall = item; } public bool getTreasure() { return hasTreasure; } public void setTreasure(bool item) { hasTreasure = item; } public int getWeight() { return weight; } }// end class In another class, I have a 2-Dim array that looks like this NavigationMesh[,] mesh; mesh = new NavigationMesh[502,502]; I use a double for loop to assign this, my problem is I cannot get the data I need out of the Vector3 node object after I create this object in my array with my "getters". I've tried making the Vector3 a static variable, however I think it refers to the last instance of the object. How do I keep all of these object in memory? I think there being garbage collected. Any thoughts?

    Read the article

  • Inheritance domain classes in Grails

    - by Tomáš
    Hi gurus how can I get Collection of specific Class? I use inheriance: On Planet live Human. Humans are dividing to Men and Women. class Planet{ String name static hasMany = [ humans : Human ] } class Human{ String name static belongsTo = [Planet] } class Man extends Human{ int countOfCar } class Woman extends Human{ int coutOfChildren } now a neet to get only Collection of Man or Collection of Woman: get all humans on planet is simple all = Planet.get(1).humans but what can I get only woman or men? womenLivedOnMars = Planet.get(1).getOnlyWoman menLivedOnJupiter = Planet.get(2).getOnlyMan Thanks for your help Tom

    Read the article

  • Question about gets and sets and when to use super classes

    - by Nazgulled
    Hi, I have the following get method: public List<PersonalMessage> getMessagesList() { List<PersonalMessage> newList = new ArrayList<PersonalMessage>(); for(PersonalMessage pMessage : this.listMessages) { newList.add(pMessage.clone()); } return newList; } And you can see that if I need to change the implementation from ArrayList to something else, I can easily do it and I just have to change the initialization of newList and all other code that depends on what getMessageList() returns will still work. Then I have this set method: public void setMessagesList(ArrayList<PersonalMessage> listMessages) { this.listMessages = listMessages; } My question is, should I use List instead of `ArrayList in the method signature? I have decided to use ArrayList because this way I can force the implementation I want, otherwise there could be a mess with different types of lists here and there. But I'm not sure if this is the way to go...

    Read the article

  • Casting between classes that share the same interface

    - by Chad
    I have two interfaces IHeaderRow, and IDetailRow I then have an object that implements both RawRow:IHeaderRow, IDetailRow I then need to cast it to HeaderRow which implements IHeaderRow. But when I try, it ends up being null or giving an exception. I can cast ObjectRawRow to either interface IHeaderRow, or IDetailRow var ObjectIHeaderRow = ObjectRawRow as IHeaderRow; var ObjectIDetailRow = ObjectRawRow as IDetailRow; But I can not cast ObjectRawRow to HeaderRow , or ObjectIHeaderRow to HeaderRow. It throws the error Cannot convert source type 'IA' to target type 'A' I need to cast it into the actual class HeaderRow. Thoughts?

    Read the article

  • C# Calling Methods in Generic Classes

    - by aip.cd.aish
    I am extending the ImageBox control from EmguCV. The control's Image property can be set to anything implementing the IImage interface. All of the following implement this interface: Image<Bgr, Byte> Image<Ycc, Byte> Image<Hsv, Byte> Now I want to call the Draw method on the object of the above type (what ever it may be). The problem is when I access the Image property, the return type is IImage. IImage does not implement the Draw method, but all of the above do. I believe I can cast the object of type IImage to one of the above (the right one) and I can access the Draw method. But how do I know what the right one is? If you have a better way of doing this, please suggest that as well.

    Read the article

  • Applet class loader cannot find one of the classes in the jar

    - by Chry Cheng
    I get the ff. error in Java Console occassionally: Exception in thread "thread applet-my.package.MyApplet-10" java.lang.NoClassDefFoundError: another/package/SomeClass at my.package.MyApplet.init(MyApplet.java:95) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: another.package.SomeClass at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 3 more Caused by: java.io.IOException: open HTTP connection failed:https://myserver/mycontext/applets/another/package/SomeClass.class at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more My applet tag is as follows: <applet codebase="../../applets" code="my.package.MyApplet" class="invisible" id="myApplet"> <param value="value0" name="param0"/> ... <param value="valueN" name="paramN" /> <param value="folder/myApplet__0.0.1177.jar,folder/commons-io-1.3.2__0.0.1177.jar,..." name="cache_archive"/> <param value="0.0.1177.0,0.0.1177.0,...," name="cache_version"/> </applet> It is important I stress the word "occasionally". Sometimes the applet is initialized without a hitch. This also means that, often, when the browser is restarted, the problem goes away. I am aware of http://stackoverflow.com/questions/698890/applet-fails-to-load-class-from-jar and http://stackoverflow.com/questions/872905/applet-class-loader-cannot-find-a-class-in-the-applets-jar but I think they are not applicable to my case. SomeClass and MyApplet are in the same jar and the page is being accessed locally.

    Read the article

  • How can I modify my classes to use it's collections in WPF TreeView

    - by Victor
    Hello, i'am trying to modify my objects to make hierarchical collection model. I need help. My objects are Good and GoodCategory: public class Good { int _ID; int _GoodCategory; string _GoodtName; public int ID { get { return _ID; } } public int GoodCategory { get { return _GoodCategory; } set { _GoodCategory = value; } } public string GoodName { get { return _GoodName; } set { _GoodName = value; } } public Good(IDataRecord record) { _ID = (int)record["ID"]; _GoodtCategory = (int)record["GoodCategory"]; } } public class GoodCategory { int _ID; string _CategoryName; public int ID { get { return _ID; } } public string CategoryName { get { return _CategoryName; } set { _CategoryName = value; } } public GoodCategory(IDataRecord record) { _ID = (int)record["ID"]; _CategoryName = (string)record["CategoryName"]; } } And I have two Collections of these objects: public class GoodsList : ObservableCollection<Good> { public GoodsList() { string goodQuery = @"SELECT `ID`, `ProductCategory`, `ProductName`, `ProductFullName` FROM `products`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new Good(rdr)); } } } } } public class GoodCategoryList : ObservableCollection<GoodCategory> { public GoodCategoryList () { string goodQuery = @"SELECT `ID`, `CategoryName` FROM `product_categoryes`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new GoodCategory(rdr)); } } } } } So I have two collections which takes data from the database. But I want to use thats collections in the WPF TreeView with HierarchicalDataTemplate. I saw many post's with examples of Hierarlichal Objects, but I steel don't know how to make my objects hierarchicaly. Please help.

    Read the article

  • How to access GDI+ Effect Classes in C#

    - by Badeoel
    Hello everybody, I try to find out, how to access the Effect-Class and it's decendants of GDI+ in C#. Especially, I'm interested in these: * Blur * Sharpen * Tint * RedEyeCorrection * ColorMatrixEffect * ColorLUT * BrightnessContrast * HueSaturationLightness * ColorBalance * Levels * ColorCurve Can anybody give me a hint, how to access them in C#? I even can't find them in the .net documentation. Do I have to access the gdilus.dll directory? Ciao! Christian

    Read the article

  • Uses for static generic classes?

    - by Hightechrider
    What are the key uses of a Static Generic Class in C#? When should they be used? What examples best illustrate their usage? e.g. public static class Example<T> { public static ... } Since you can't define extension methods in them they appear to be somewhat limited in their utility. Web references on the topic are scarce so clearly there aren't a lot of people using them. Here's a couple:- http://ayende.com/Blog/archive/2005/10/05/StaticGenericClass.aspx http://stackoverflow.com/questions/686630/static-generic-class-as-dictionary

    Read the article

  • Abstract classes in shared library

    - by JTom
    Hi, I have an ordinary abstract class that has couple of pure virtual methods. The class itself is a part of the shared library. The compilation of the shared library itself is OK. But when the library is linked to another program that has another class deriving from the abstract one in the shared library and defining the pure virtual methods, I get the following linker error: I compile like this..: g++ -I../path/to/the/library main.cpp derived.cpp -L../path/to/the/library -lsomename -o shared ...and the linker error is: libsomename.so: undefined reference to `AbstractClass::method()' It's like the abstract class cannot access its pure virtual methods but I do not try to make any instance of the abstract class anywhere in the library. What could be the problem?

    Read the article

  • How to make some functions of a class as private for third level of inheritance.

    - by Shantanu Gupta
    I have created a class say A which has some functions defined as protected. Now Class B inherits A and class C inherits B. Class A has private default constructor and protected parameterized constructor. I want Class B to be able to access all the protected functions defined in Class A but class C can have access on some of the functions only not all the functions and class C is inheriting class B. How can I restrict access to some of the functions of Class A from Class C ? Class A { private A(){} protected A(int ){} protected calc(){} protected allow(){} } Class B : A {} // calc() and allow() should be accessible here CLass C:B { // calc() should not be accessible here but allow() should be accessible here. }

    Read the article

  • Scope of Nested Classes

    - by Vaccano
    If I have a nested class, does anything from the owning class exist in the owned class? for example: public class OwningClass { int randomVariable = 1; public void MakingMethod() { OwnedClass owned = new OwnedClass(); owned.SomeMethod(); } private class OwnedClass { public void SomeMethod() { // Is anything from OwningClass available here? } } }

    Read the article

  • Java: JPA classes, refactoring from Date to DateTime

    - by bguiz
    With a table created using this SQL Create Table X ( ID varchar(4) Not Null, XDATE date ); and an entity class defined like so @Entity @Table(name = "X") public class X implements Serializable { @Id @Basic(optional = false) @Column(name = "ID", nullable = false, length = 4) private String id; @Column(name = "XDATE") @Temporal(TemporalType.DATE) private Date xDate; //java.util.Date ... } With the above, I can use JPA to achieve object relational mapping. However, the xDate attribute can only store dates, e.g. dd/MM/yyyy. How do I refactor the above to store a full date object using just one field, i.e. dd/MM/yyyy HH24:mm?

    Read the article

  • NullPointerException when trying to run an applet of multiple classes

    - by Chad
    I'm trying to display an applet in an html page. I've had success doing this in the past, but now that I have more than one class in the applet, I seem to get an error every time I try to load the applet in an html page. For a bit, I was writing the html page by hand, but then I realized the applet viewer in netbeans (the IDE I'm coding in) created an html page for you, which is the same as the one I was coding. The application runs error-free when in the applet viewer, but the following message is displayed when I try to run it in the html page: java.lang.NullPointerException at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.NullPointerException I tested another small, one class applet and it ran fine in the html page under the same conditions. Any ideas what may be wrong?

    Read the article

  • Using StructureMap to create classes by a name?

    - by Bevan
    How can I use StructureMap to resolve to an appropriate implementation of an interface based on a name stored in an attribute? In my project, I have many different kinds of widgets, each descending from IWidget, and each decorated with an attribute specifying the kind of associated element. To illustrate: [Configuration("header")] public class HeaderWidget : IWidget { } [Configuration("linegraph")] public class LineGraphWidget : IWidget { } When processing my (XML) configuration file, I want to obtain an instance of the appropriate concrete class based on the name of the element I'm processing. public IWidget CreateWidget(XElement definition) { var kind = definition.Name.LocalName; var widget = // What goes here? widget.Configure(definition); return widget; } Each definition should result in a different widget being created - I don't need or want the instances to be shared. In the past I've written plenty of code to do this kind of thing manually, including writing a custom "roll-your-own" IoC container for one project. However, one of my goals with this project is to become proficient with StructureMap instead of reinventing the wheel. I think I've already managed to set up automatic scanning of assemblies so that StructureMap knows about all my IWidget implementations: public class WidgetRegistration : Registry { public WidgetRegistration() { Scan( scanner => { scanner.AssembliesFromApplicationBaseDirectory(); scanner.AddAllTypesOf<IWidget>(); }); } } However, this isn't registering the names of my widgets with StructureMap. What do I need to add to make my scenario work? (While I am trying to use StructureMap in this project, an answer showing me how to solve this problem with a different DI/IoC tool would still be valuable.)

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >