Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
3 answers
649 views

Object Oriented Programming - what is the best way to add new parameters?

I have a doubt about what would be the right OOP approach for implementing classes that do similar stuff with different parameters. To provide a simple example, I would use two polynomial classes, ...
ThePunisher's user avatar
-1 votes
2 answers
186 views

Is an abstract role needed to ensure that a customer can only have one role out of several? [closed]

I have the following UML class diagram in a C++ context. I want to make sure that a Customer can have only one role: Can the Customer now only assume one role, and what does <<abstract>> ...
Seonix's user avatar
  • 11
0 votes
3 answers
277 views

Java Inheritance Problem

I have the finance application where we can have different types of transactions, like balance enquiry, funds transfer, and pin change etc. Now the Transaction is a base class, and there are specific ...
rahul sharma's user avatar
5 votes
1 answer
2k views

How to go ahead with methods that only one derived class implements from a common interface?

I have one interface (let's say in C++) that has been implemented by some derived classes. Let's suppose that the interface is like this: class IBase { virtual bool method_1() = 0; virtual long ...
TonySalimi's user avatar
17 votes
4 answers
4k views

When to move a common field into a base class?

I currently have two derived classes, A and B, that both have a field in common and I'm trying to determine if it should go up into the base class. It is never referenced from the base class, and say ...
samus's user avatar
  • 475
1 vote
3 answers
680 views

Should a property be in an abstract class if not directly used

I have an abstract base class that is inherited by several different other types. They were all using a type injected into their constructor. So I moved this property in to the abstract base class. ...
DasDave's user avatar
  • 121
2 votes
1 answer
102 views

Feedback on inheritance assignment

So I've got this java assignment for college and was just wondering if anyone here could give me some feedback as to what I've been thinking some of this means. I've got a .csv file with building ...
screencut's user avatar
2 votes
2 answers
960 views

Is there a best practice to forward method overrides while enforcing method execution?

Sometimes i have code along the lines of this: public abstract class A { protected abstract void DoSomething(); }   public abstract class B : A { /// <...
Dbl's user avatar
  • 129
0 votes
1 answer
539 views

How to design inheritance from abstract class which is not initiated but seemingly must be initiated?

I need to design a program in Java which calculates arithmetic expressions (only addition or subtraction). Requirements: 1) abstract class Expression which contains abstract method calculate()...
Yos's user avatar
  • 167
3 votes
1 answer
525 views

Best design for classes that draw objects but do not inherit from JPanel

I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition). Modify the MyLine, MyOval and MyRectangle classes of GUI to create ...
Yos's user avatar
  • 167
1 vote
2 answers
634 views

Options for derived classes of two abstract base classes

Let's say there are classes D1, D2, etc. describing different types of an abstract class D. Let's say there are SenderReceiver classes describing different ways of communicating for each D1, D2, etc.:...
Mark Lodato's user avatar
1 vote
1 answer
210 views

Is it valid to create superclass instance in OOP?

I have couple of files in my folder, some of them can be checked for integrity. I have a xml file which describes which files can be checked for integrity and their checksum. In OOP, let's assume I ...
Tahnik Mustasin's user avatar
8 votes
3 answers
30k views

C++ derived class copy constructor

If I have an abstract class Drink which has a derived class Coffee, what would the copy constructor for Coffee look like? If it accepts a reference of Type Coffee as a parameter then I wouldn't be ...
FoxTrod's user avatar
  • 83
0 votes
1 answer
166 views

Inheritance and polymorphysm conundrum

Okay, I'm trying to write something resembling a 3D game engine. That means I have to deal with matrix transformations and similar stuff. For any of you who don't know, you need to use three basic ...
Karlovsky120's user avatar
4 votes
1 answer
235 views

Inheritance from children to parents?

Seeing this UML class diagram : FileHandler, Uploader and Deleter are abstract classes. The four bottom classes are implementations. They extend on FileHandlerInterface which requires a handle method ...
Steve Chamaillard's user avatar

15 30 50 per page