Most voted "oop" questions
Object orientation is a paradigm of analysis, design and programming of software systems based on the composition and interaction between several units of software called objects.
Learn more…1,456 questions
Sort by count of
-
1
votes1
answer111
viewsPython help in object orientation
What’s wrong with this code? Compiler points error on line 8... class Pai(object): Nome='Carlos' Sobrenome='Maria' Residencia='Rio de Janeiro' class Filha(Pai): Nome='Luciana' def __init__(self,…
-
1
votes1
answer269
viewsAdd sub property dynamically
class ObjetoSimples{ var $nome; var $cargo; var $turno; } class ObjetoComposto{ var $nome; var $setor; var $equipe; } How to add new nome with turno and cargo in equipe? For example:…
-
1
votes1
answer93
viewsC# Floating Form
Good, I’m making a program where I need a floating form that accompanies the mouse cursor while it’s inside a button, so far I have this: private void portaSwitchUpLink_MouseEnter(object sender,…
-
1
votes1
answer81
viewsForm only works the second time
I made a form log in and it all worked out. But you have a bug, only log in on the second try. It’s in MVC standard: Controller: public function index() { if(!$this->model->isUserLoggedIn()) {…
-
1
votes1
answer3521
viewsDiscover the object class in Java
I have a set of functions to configure a set of parameters in Java like this: public void Util.setParametros(Integer par) {} public void Util.setParametros(String par) {} public void…
-
1
votes0
answers58
viewsWhat is the advantage of using C#Interface?
Is there a specific scenario for using Interfaces ? If so, how can I know when to use? I’ve always wanted to use in the projects I’ve been creating, but I never know the right time. I know that it…
-
1
votes2
answers182
viewsObject Life Time in PHP - How many Controller instances?
I have a controller that runs the index method for the main page. A button in profile information is called by a route that falls into the registration method. The instance that was executed when…
-
1
votes3
answers717
viewsHow to list files in a directory?
I use the following code : $path = 'pasta_desejada'; $dir = new DirectoryIterator($path); foreach ($dir as $fileInfo) { $ext = strtolower( $fileInfo->getExtension() ); if( in_array( $ext, $types…
-
1
votes1
answer53
viewsJava Socket Specification and Implementation
I created a class MySocket that extends java.net.Socket, but I saw that class java.net.Socket implements the interface java.io.Closeable, and my question is: In my class MySocket I am obliged to…
-
1
votes1
answer640
viewsHow to use C# Windows Forms with Firebird and Object Orientation?
I recently learned a little object orientation and c#. But I am trying to create an application that is developed in c# windows Forms, with database Firebird and object-oriented. But what’s the…
-
1
votes2
answers37
viewsInclusion of method in own class
Imagine a sistema OO which has at least 2 classes: Admins.php Clientes.php In real life, that is, in the system, customers cannot register. In this case, the function of registering the Customer is…
oopasked 8 years, 4 months ago Carlos Rocha 1 -
1
votes0
answers80
viewsWhat are Abstract Classes
Why should we use an abstract class? in what situation? is the same thing as interfaces? What are the advantages and disadvantages of using?
-
1
votes2
answers100
viewsI define a value in a class, when I instate the same value is another
This is the code where I defined a class Animal is a breeding method that asks the species of the animal and defines its state as alive: public class Animal { public bool estaVivo, usaDrogas =…
-
1
votes2
answers1143
viewsReceive variables from other classes
A class that contains variables and their values, and needs some simple way to feed the other class with these variables. For example, I have a class with the variable String urlPage =…
-
1
votes3
answers752
viewsComparison between objects through loop, If and Else?
I’m beginner in java and I’m having doubts in comparing objects by means of loop. I am developing software for a video rental company with Pattern MVC (Model-view-controller) design and I want to…
-
1
votes0
answers43
viewsWhen to use static methods?
I am working on a project and as a base I am using another for reference. However, in this other project almost all methods are declared as static. This is good practice? What are the advantages or…
-
1
votes4
answers110
viewsWhy this division in the class instantiation in C#?
In the book "Use the Head - C#", the author declares classes in a way that I did not understand their usefulness, according to the example: public partial class Form1 : Form { Farmer farmer; public…
-
1
votes1
answer1923
viewsReturn javascript object
var Mensagem = function(opcoes){ var padrao = { titutlo: "", msg: "", lido: false } var config = $.extend(padrao, opcoes); this.prototype = config; } var msg = new Mensagem({ titulo: "Olá mundo!",…
-
1
votes1
answer128
viewsCalling multiple methods in the same instance of a PHP class
I wonder how I can do that: Class::methodA()->methodB()->methodC()...; I have a View class (MVC) in which I step parameters to create variables (assign). Currently it looks like this:…
-
1
votes1
answer448
viewsApplication of the Singleton standard for small/large design
I’m building classes for an old project where I used only functions in different files. The goal is clear, to create a reusable code standard for small-scale projects with not very distinct…
-
1
votes2
answers137
viewsPrevent classes from changing the state of objects
How to prevent classes from modifying the object state of a class, both Within equal and separate packages? Assuming there is a Pattern to design a java class design that can or even affects the…
-
1
votes1
answer193
viewsWhat’s that part of the code called?
Let’s say I create a class... public class Teste1 { public void Teste1(){ System.out.println("Olá"); } public void teste2(){ System.out.println("Oi"); } } The Teste1 is the constructor method of the…
-
1
votes1
answer53
viewsHow do I resolve the prepare error for this script?
I’ve been looking for a solution for 2 hours [this problem][1]. I am starting a course of Virtual store with PHP and the mistake is this: he says I’m trying to give a prepare in an unincorporated…
-
1
votes1
answer58
viewsC++: Instances of the same class
I have in a project a class Collision, and to make detection more efficient, wanted to have access to all instances (objects) of that same class. Is there any easy way to do this? Edit 1 I did this:…
-
1
votes1
answer40
viewsI would like suggestions about this structure in JS
Good afternoon. Practicing a little, I decided to build a javascript slider, and chose to follow this construction line with a builder. The code is functional. However, I would like to encapsulate…
-
1
votes1
answer83
viewsException in Split()
I have in my system an index of terms, know which word is being used most among the messages of the users, for this, I created a class Termos and I made a loop to generate a new object for each…
-
1
votes1
answer431
viewsHow to send attributes to extended classes?
class Veiculos { protected $tipo = "carro"; } Below I am trying to identify which type of vehicle the class Veiculos assigned. I created a function tipo_veiculo that should show the user what type…
-
1
votes2
answers287
viewsCreate product classes and photos and initialize
I have a class Produto and within that class I have a class Categoria and a Class Foto. 1 Product may have only 1 category, but may have multiple Photos. The problem is with the photos. I did so:…
-
1
votes1
answer97
viewsHow to remove the warning not to use VAR in Netbeans?
Right here in the OS, I saw that I no longer need to use VAR, when declaring a variable in PHP, this was only until PHP4. Netbeans keeps giving error, if I don’t use, and use only the variable How…
-
1
votes2
answers925
viewsUsing $this in POO PHP
I don’t quite understand what $this "gets". In this case we have a code like this, for example: <?php class Teste { public $testando; public function VamosTestar(){ this->$testando = false; }…
-
1
votes1
answer179
viewsHow does class inheritance work in C#?
I have class 1 and class 2, class 2 inherits from class 1. Other classes that inherit from class 2 will inherit the attributes of class 1?
-
1
votes4
answers708
viewsConversion of interface list into object list: (List<Interface> in List<Object>)
I need to convert a IList<Interface> in a List<Objeto>. Take the example: public interface IObjetosBase { IList<IObjetosBase> get(); } public class ObjetosBase : IObjetosBase {…
-
1
votes1
answer337
viewsHow to create an abstract class in C++?
In C++ virtual uses file . cpp #ifndef TETES_H #define TETES_H class Tetes { public: Tetes(); virtual ~Tetes(); virtual void exibeDados(); protected: private: }; #endif // TETES_H file . h #include…
-
1
votes2
answers590
viewsA person can have multiple phones. How to do this with vector and not with list?
I’m having trouble connecting Telefone with class Pessoa, a person can have up to three phones. How does this? package model; public class Pessoa { private String nome; private String endereco;…
-
1
votes1
answer123
viewsPrivate variable error in C++
I can’t understand why I’m making this mistake when compiling my code: In file included from test_GenericArray.cpp:2:0: Genericarray. h: In Function ːStd::ostream&…
-
1
votes3
answers159
viewsApplying Interface in Controllers
I have some controllers who call upon their respective models and would like to apply interface on them. I have created an interface with some methods that it would be important for everyone to…
-
1
votes1
answer69
viewsHow to pass the class (Teste2 teste2) as reference in the ("super") C++ constructor?
On the basis of that reply In C++ what command corresponds to super() of Java? Class Teste2{ int x; int y; public: Teste2(int x, int y){ . . . } } class Testando{ Teste2 *teste2; public:…
-
1
votes1
answer185
viewsClass declaration in C#
What other access levels can I declare a class in C# besides public and private. I found these levels in the microsoft website: protected internal protected internal…
-
1
votes2
answers5641
viewsWhat is the use of the word "self" in Python?
excuse my ignorance on the subject because I’m starting now in the Python language, and for this very reason I wanted to know what works the reserved word "self". Thanks for your attention and…
-
1
votes1
answer251
viewsHow to reference instance variable with the same name as a local variable in C++?
In C++, how can I reference an instance variable that has the same name as a global variable? For example, in a set method of the following class: class Person { private: string name; public: void…
-
1
votes1
answer103
viewsMethod override of an interface
I’m having a question about the method override of an interface. I can override a method in a daughter class that inherits from the mother class the implementation of an interface and in that method…
-
1
votes2
answers250
viewsObject error not instantiated
I have a model calling for ClientesModel. Inside it I have the fields: public int id { get; set; } public int codcli { get; set; } public string nome { get; set; } public string endereco { get; set;…
-
1
votes1
answer281
viewsApplication of algorithms in POO
The programming algorithm/logic is geared towards structured programming. How would it apply algorithm in POO?
-
1
votes2
answers182
viewsCan an object be instantiated?
I am reading a code and it appears with the following line $this->controlador = new HomeController(); $this->controlador = new $this->controlador( $this->parametros ) My question is as…
-
1
votes0
answers485
viewsCall to a Member Function prepare() on null in
I got this class that connects to Mysql through PDO, in this link. It works just fine. But I decided to turn it into a static class. And here’s the modified code. class db { private static $dsn;…
-
1
votes1
answer331
viewsProblems with Cielo Library and communication with Codeigniter
I am implementing the communication with Cielo servers for a system of my. However, when I try to load the Cielo library, I get an error. The folder structure is as follows: third_party / Cielo /…
-
1
votes1
answer272
viewsDo php’s autoload functions make an object available to any part of the site in the same session, even in different subdirectories?
I intend to make my code cleaner and therefore avoid using include or include_once all page start. I would not like to use frameworks that already do this work as Windows for example. I want to…
-
1
votes1
answer59
viewsHow to define a subclass of an abstract class so that it is concrete
With these classes: class SerVivo { public: virtual void funcA() = 0; virtual void funcB() = 0; }; class Vegetal : public SerVivo{ public: virtual void funcB(){ cout << "funcB em Vegetal \n";…
-
1
votes1
answer118
viewsGeneric vector with error
I’m concluding this generic vector activity, but I’m having trouble returning the last and first element of the list. and to remove the element. public class Vetor<T>{ T[] vetor; int…
-
1
votes0
answers139
viewsCustomer-supplier relationship model
Long ago I asked a question here about modeling clients using object orientation. What I took from the answers is that customers, suppliers, and so on, rather than being characterized as entities…