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
-
2
votes2
answers92
views -
2
votes1
answer63
viewsBest way to apply the concept of Object Orientation
I own a class Usuario class Usuario{ } Let’s say that this user needs to access some different Web Services for resources and information. I then thought about creating a class called WebService and…
-
2
votes2
answers4781
viewsHow to store data from a. txt file in an object - Java
I am beginner in programming and am making a small application that should register products, delete, edit, organize, control inventory, cost price, selling price, profit margin, etc. So far I have…
-
2
votes1
answer347
viewsWhat is the difference between Abstraction and Implementation?
I’d like to know the difference between Abstração and Implementação, and how this applies in practice!
-
2
votes2
answers152
viewsWhat is the difference between instantiation in the same variable or in 3 different variables?
Follows part one: class Pessoa{ String firstName String lastName int age def address static main(args) { def p = new Pessoa() p.setFirstName("Lars") p.lastName = "Vogel" p.address = "Homestreet 3"…
-
2
votes3
answers73
viewsas by values within objects
I have a "span" with properties date: <span data-label="Name" data-icon="user"></span> And in the script I have a variable with objects: var widgets = { options: { label: null, icon:…
-
2
votes2
answers96
viewsC++: File header not recognizing class
I am working with several classes, and to organize myself better, I put each class in a different file. actor. h #ifndef ACTOR_H #define ACTOR_H #include "SDL.h" #include <string> #include…
-
2
votes1
answer865
viewsPython to C++ conversion
I work on my course with C++, and wanted to use a Python class variable access feature. See an example: class Telefone: nums = {} def __init__(self, numero): self.num = numero Telefone.nums[numero]…
-
2
votes1
answer1104
viewsTake and display data from a class attribute (class association)
I’m having a little trouble picking up a value from an attribute of the type class. Classe Pessoa public class Pessoa { public string Nome {get;set;} public int Idade {get;set;} public virtual void…
-
2
votes2
answers1621
viewsNon-static method cannot be referenced from static context?
I was watching the programming class in java and basically the business was to calculate the total area of a house with a pool, however, I’m having difficulties. Basically I separated everything…
-
2
votes1
answer74
viewsWhy "new Array" after variable?
Why put new Array after the variable name? Example: var weatherPattern = new Array('Clouds', "raining", "clowdy");
-
2
votes1
answer797
viewsOrder of class initialization/instantiation
class Bird { { System.out.print("b1 "); } public Bird() { System.out.print("b2 "); } } class Raptor extends Bird { static { System.out.print("r1 "); } public Raptor() { System.out.print("r2 "); } {…
-
2
votes4
answers151
viewsHow to build a class correctly with access methods?
How do I join several variables into a single object? How do I arrange the following code? <?php class Produto { //Atributos var $cpu; var $mb; var $psu; //Getters & Setters function…
-
2
votes4
answers1502
viewsHow to inherit more than one class in PHP?
There is the possibility of inheriting two classes in PHP? I have a class that already inherits the class Usuarios and would like her to inherit the class Crud also. class Alunos extends Usuarios {…
-
2
votes1
answer146
viewsWhat is the difference between Static::Property, Classname::property, self::property?
I know that the parent::propriedade, you select parent property, but I’m not able to differentiate these other three when I use within the scope of the class. Both work, but what’s the difference?…
-
2
votes1
answer286
viewsOne method stopping the loop of another method
I have four objects (already instantiated) triangle, square, circle and a last picture, responsible for invoking both methods of each class of the respective objects, in order to draw a house, a…
-
2
votes1
answer421
viewsDefining an abstract attribute in a non-extabstracted class
I want to be able to instantiate an employee class (so this can’t be abstract) and have an abstract salary attribute that will be static for each type of employee. I can do (in the working class):…
-
2
votes3
answers927
viewsHow to declare an attribute in interface?
How can I declare some attributes in an interface? Example, I have the interface called animal, I want her to have some attributes that class mamifero will implement, but the attribute I declare in…
-
2
votes2
answers197
viewsJava polymorphism
In the context of inheritance, when B is sub-class of A, an instance of B can be used anywhere where an A is valid. This is the characteristic of polymorphism. However I have a question. I know it’s…
-
2
votes3
answers342
viewsWhere should I put a calculation method? In the entity itself or in the business class?
I have an architectural doubt, I believe. I need to create a method that receives a period of dates and an entity in which to execute a search in the period cited. In fact, to ask this question it…
-
2
votes1
answer56
viewsHow to save in a single vector, base and derivative classes?
I have a work in C++, and I need to write to a single vector, a base class, and two derivatives. How to do this vector?
-
2
votes1
answer124
viewsClass organization
I need to create a system of posts. I’m having a hard time studying class and I’m wondering which of the two ways to use it: class publicarPost {} class excluirPost {} class curtir {} or class Post…
-
2
votes2
answers569
viewsConstructors in PHP 7
I was testing a class in PHP 7, and noticed that the constructor no longer works when it is created from the class name, working only when it is created with the name __construct. Example: <?php…
-
2
votes1
answer239
viewsException in thread "main" java.lang.Nullpointerexception: Calculator
I started studying Object Orientation and decided to make a simple calculator program. At the moment I just made the sum to see if the way I was doing is right. Follows the code: package…
-
2
votes1
answer58
viewsWhy do we use the Containerinterface when injecting @service_container as argument?
In the archive services.yml I have the following service configured: services: api.response_factory: class: AppBundle\Api\ResponseFactory arguments: ['@service_container'] In class ResponseFactory I…
-
2
votes1
answer184
viewsPOO in Java - World Cup Modeling
I am entering the universe of Object Orientation and, moved by curiosity, I decided to try to simulate the organization of a World Cup through these concepts. Well, I’m having some difficulties with…
-
2
votes3
answers1106
viewsClasses with associations in UML
I’m from the time of structured programming and now I’m returning and trying to fit in with OOP. I made a diagram below. I’m on the right track? I created this class Empresa thinking of not having…
-
2
votes1
answer128
viewsAnalogy between POO and database
I’ve been reading about the Entity Framework, that it has some features of transforming classes into tables and objects into lines. I found it super interesting! To what extent is this analogy…
-
2
votes1
answer44
viewsInstance declared in variable that then receives a new value
I have the following code: $config = new \Skreth\System\Config(dirname(__DIR__) . '/config/config.ini'); $config = $config->getProperties(); I create a declared instance in the variable $config…
-
2
votes1
answer221
viewsCall methods and catch exception
I created three classes, an abstract class called Form, a class Retangulo extending Forma and a class programa, containing the method Main. My intention is in the "program" class to receive the…
-
2
votes1
answer321
views -
2
votes1
answer65
viewsAdding an object to a collection returns "cannot be cast to java.lang.Comparable"
The code is this: public class Catalogo { SortedSet<Produto> lProdutos = new TreeSet(); public void addProduto(int cod, String desc, float preco){ try{ Produto p = new Produto(cod, desc,…
-
2
votes1
answer154
viewsDoubts about class composition or inheritance
I’m having some doubts in that composition between the ClienteJuridico and Clientephysics with the NotaFiscal. I did some research and saw that the objetos of these classes within another, in case…
-
2
votes1
answer292
viewsObject assignment in Python
Can anyone tell me why in the first iteration the assignment retangulo=retangulo() works, but on Monday? This error appears in Pycharm: <<'rectangle' Object is not callable>> Code: from…
-
2
votes1
answer1214
viewsIs VBA object oriented?
VBA can be considered an object-oriented language? Despite having getters and setters (or Letters… rsrsrs), implementation of classes, methods and attributes, lacks the concepts of encapsulation,…
-
2
votes2
answers1639
viewsHow to Instantiate an Object in C#
How do I instantiate an Object in another class? I’m trying this way: GameObject Cozinha = new GameObject("CenaCozinha"); CenaCozinha coz = Cozinha.AddComponent<CenaCozinha>(); But I believe…
-
2
votes2
answers180
viewsDoubt about Python derived class initialization
Imagine I have a base class Food and create a second class Rice that will inherit the class functionalities Food. If at the time of initializing, what difference does it make if I do: class…
-
2
votes1
answer144
viewsSkyrim style item system
I am developing a 2D RPG in C# Skyrim style, and I am on the part of implementing the game items, but with many difficulties. I wanted to do a mechanics similar to Skyrim in which you have a range…
-
2
votes1
answer55
viewsHow to send variable value into php class?
I have been perfecting the techniques of safe use with database connection and arrived at the script below. <?php class query_sql { protected static $conect; private function __construct() {…
-
2
votes4
answers318
viewsHow to return an object from a dynamic reference in Javascript?
I need to create a Javascript code that returns an object already created with a dynamic reference by its name/id. Basically this: // Define class function Test(num) { this.msg = "Message"; this.num…
-
2
votes1
answer9626
viewsWarning: Invalid argument supplied for foreach()
I have the following select: public function SelectLastError(){ try { $stmt = $this->conn->prepare("SELECT Name, Data FROM Errors ORDER BY ErrorsId DESC LIMIT 3"); $stmt->execute(); while…
-
2
votes3
answers89
viewsError calling a secondary method via CALLBACK: Uncaught Typeerror: Cannot read Property 'secondarily named' of Undefined
With Javascript (Ecmascript-6), when calling a method via callback, if this method uses another method the following error occurs: Uncaught Typeerror: Cannot read Property…
-
2
votes0
answers28
viewsDoubt about inheritance in Python
Hi, I’m studying POO in Python and saw that you can inherit the attributes of a super class in two ways: Class nome_da_classe(nome_da_superclasse): def __init__(self, args):…
-
2
votes1
answer112
viewsIs there a means of "mirroring" properties of one object into another?
Say I want to do a function debugText(obj), this function takes an object as a parameter and shows a property of it on the screen, such as debug game screens. Something like: function…
-
2
votes0
answers55
viewsWhat are the benefits of object orientation?
Encapsulation allows isolating changes in the implementation code without affecting the interface offered by the class. It does not allow the internal state to commit to the client of the class…
-
2
votes1
answer114
views -
2
votes1
answer7703
viewsCall method by form action
Is it possible to call a method via post by the form action? How? <?php class Produto { public function insere() { $nome = $_POST['nome']; $descricao = $_POST['descricao']; $preco =…
-
2
votes1
answer516
viewsDifference between using struct and class to create an object
He had already "learned" object orientation in college, right on top of it. Now that I’ve started to revise I realize that no matter how much they say structs do not form objects, I really see no…
-
2
votes4
answers479
viewsRemove object from an Arraylist
I have an arraylist of objects, and I need to remove an object from it as follows. I need this object to be removed if its box attribute stores the same value that was typed in mine TextBox. Why am…
-
2
votes3
answers556
views