Question Class, abstract... HOW?

Pavle78

New member
Joined
Dec 26, 2018
Messages
2
Programming Experience
Beginner
Hello everyone.
I have one question, a task. I hope it is by the rules of the forum. If it is not, let the admins erase it. I'm a beginner.
I have a task:
Task 1. There are two types of IndividualAccount and CorporateAccount accounts.
IndividualAccount has the following features:
1. AccountNumber,
2. Code,
3. Flags (IsBuyPrevented, IsSellPrevented, IsWithdrawalPrevented),
4. AccountStateType (Open, Closed, Locked)
5. User (FirstName, LastName, Address (City, Country, PostalCode, Street)).
CorporateAccount has the following features:
1. AccountNumber,
2. Code,
3. Flags (IsBuyPrevented, IsSellPrevented, IsWithdrawalPrevented),
4. AccountStateType (Open, Closed, Locked)
5. CorporateLegalName
6. AuthorizeAgent (is the User class with the same characteristics as the IndividualAccount)
7. Phone


Create the above class that describes the previous scenario. When creating, use an abstract class where it is possible.

I do not know how to begin to solve the task. And how to get started to write the code?! Any kind of help is welcome. Thank you.
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,813
Location
Sydney, Australia
Programming Experience
10+
We don't know what you know and what you don't but, if you have been tasked with this assignment, you have presumably been taught about classes, abstract classes and inheritance. Do you understand those concepts? If not, the very first thing you should do is go back over any notes or prescribed text you have that covers them try to understand them. You might also search the web for further information and examples of implementing those concepts.

I'm not sure whether there's more to your assignment than that but I'm not seeing a natural case for an abstract base class there. There is obviously common functionality between those two type that can be placed in a base class but nothing that is an obvious candidate for being declared abstract. The features you have listed seem to correspond only to properties and not to methods. While properties can be abstract, it is far more common for methods to be so. That's because property implementation tends to be quite simple so there is less scope for difference in implementation between similar classes.

As an example of where you might use an abstract class, consider classes that represent shapes that can each draw a representation of themselves on a Windows Form. You might declare a Shape class as the base for all shapes and add a Draw method to it. By doing that, you could create an array or collection of Shape objects and then loop through it and call Draw on each one, allowing you to draw multiple shapes of different types without knowing what type each one is. The Draw method would be abstract and thus so would the Shape class. That means that you would provide no implementation for the Draw method in the Shape class - how could you when you have to know what shape an object is to be able to draw it - but then each class that inherits Shape would provide its own implementation, e.g. a Circle class would implement Draw to draw a circle, etc.
 
Top Bottom