Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
subclasses
- Page 1
Subclasses
Programming
Software Development
15 Years Ago
by Filipe11
… (eg: List <Medicamentos>...), but this class has 3
subclasses
and, how I use properties ,I dont know how to…
Re: Subclasses
Programming
Software Development
15 Years Ago
by LizR
The answer would normally be you shouldnt. Please explain a little more of what you're trying to achieve before we can give you better answer
Re: Subclasses
Programming
Software Development
15 Years Ago
by ddanbe
A SUPER-class normally inherits all the methods etc. of his SUB-class. Say you have a class [B]Car [/B]and class [B]Sportscar [/B]which inherits from [B]Car[/B]. If [B]Car [/B]has an engine so will have [B]Sportscar[/B].
Re: Subclasses
Programming
Software Development
15 Years Ago
by Filipe11
I has solved this for myself, but thanks...
looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
… a not too difficult exercise which involves superclasses and
subclasses
(the java book I am reading doesn't really… something like this: Create a superclass 2DimensionalShapes and 2
subclasses
Rectangles and Triangles. I will then need to calculate… in the superclass and perhaps the methods in the
subclasses
, not sure what's best. Do you guys …
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
… the calculateArea method; just make getArea abstract and let the
subclasses
decide how to implement it. Unless you have some very… stuff going on it will be perfectly OK for the
subclasses
to calculate the area in their getArea() implementations, thus guaranteeing…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
…(); }//end of class TwoDimensionShape Now, when you say that the
subclasses
will calculate the area and perimeter themselves in their own… it is ok to declare all the variable in the
subclasses
as private?
Queue with instances of different subclasses
Programming
Software Development
14 Years Ago
by msr
… to have a PriorityQueue whose elementes are instances of different
subclasses
. For example: Event is an abstract superclass. Event1, Event2, Event3… are
subclasses
. Xpto<> is an interface and PriorityQueueXpto<>…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
… think of some way to generalise what's in the
subclasses
to allow this.
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
… in the superclass that you need to use in its
subclasses
. Oh, and the other exception is static final "variables…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
… declared in the superclass can easily be declared in the
subclasses
, more so if they are declared as abstract (now, bear…
Subclassed Editbox Control: Do I need to create 2 subclasses for two edit controls?
Programming
Software Development
18 Years Ago
by BenPage
… user type in the key? Should I rather create two
subclasses
for the edit boxes, and create a control variable for…
multiple subclasses. header files problem
Programming
Software Development
14 Years Ago
by SpyrosMet
… has two sub-classes: animals and plants. Animals has two
subclasses
itself: Carnivores and Herbivores. I have succeded in including the…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
thanks, I will build an application that does that then. > put everything you can that is used in >1 subclass in the superclass, so you only have to do it once I was thinking about that too: I was thinking to have the methods int he superclass - calculate the area and perimeter of the 2 shapes - but the way they are calculated is different…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by pritaeas
Technically, both the triangle and the rectangle can be specified by a point and two vectors ;)
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
area and perimeter are ideal candidates for abstract methods in the (abstract) superclass with concrete implementations in each subclass - ie every Shape can calculate and return its area, but exactly how that happens is different in each subclass. Sides are a bit more interesting... the two sides of a rectangle are not the same things as two sides…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
ah ok, so I should use abstract classes....ok I just read about them in my java book. Ok I will give it a go, not sure if I will implement it correctly. I will post the finished code later thanks
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
Ok so essentially my `TwoDimensionShape` abstract class will look like this: /*TwoDimensionShape.java, Superclass*/ public abstract class TwoDimensionShape{ private double area; private double perimeter; //constructor uses the empty default one because there is nothing to set //getters public double getArea…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
Right, I have done the small application that calculates the area and perimeter of a triangle and a rectangle. The files with the code are attached. Here's the output, which is what I have expected: Rectangle information: Base of rectangle is : 10.000000 Height of rectangle is : 5.000000 The area is 50.000000 The …
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
toString: you have to return the String, not print it, so what you did is OK (maybe too much detail?) The superclass isn't doing anything useful yet because you don't have a suitable test/demo case. For example - suppose this is part of some kund of graphics app - so we'll add some stuff to the superclass like: int x, y; // position of …
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
Declare them in the superclass - do it once - efficient Declare them in each subclass - do it many times - inefficient and error-prone. Your toString is OK. Don;t worry. It returns a nicely formatted String describing the object. It doesn't have to be so well formatted, or so detailed, but that's OK too.
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
Ok, I can obviously see that the idea is sound - and hey I didn't mean to criticise that, surely if everybody does that there is a good reason for it - it's just that being still at the beginning of my java trip I perhaps still don't appreciate the big picture : -)! But that toString method, I really find it bemusing at times, it's like magic in a …
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by JamesCherrill
toString is really simple, no magic at all. There are many times during development and debugging when you want to see the value of a variable. So you need a way to print/display any random Object. That's toString(). It's implemented on the Object class, so every possible object will have that method. So, for example, when you call `System.out.…
Re: looking for a inheritance exercise using super and subclasses
Programming
Software Development
10 Years Ago
by Violet_82
eh eh, ok thanks for clearing that up, hopefully I will get that in my head then! I think it was also the fomat method that I haven't come across before to confuse things. Should be ok now, thanks : - )
Re: Queue with instances of different subclasses
Programming
Software Development
14 Years Ago
by JamesCherrill
I see no-one has replied to this (wonder why???), so I'll have a go. Is the following the kind of thing you are looking for? [CODE] interface I<T extends Event> { T dosomething(T t); } class Event2 extends Event { public Event2(Object arg0, int arg1, Object arg2) { super(arg0, arg1, arg2); } }…
Re: Queue with instances of different subclasses
Programming
Software Development
14 Years Ago
by msr
Yep, that solved my question. Thank you very much!
Re: Subclassed Editbox Control: Do I need to create 2 subclasses for two edit controls?
Programming
Software Development
18 Years Ago
by Alvein
[QUOTE=BenPage]I want the user to enter the password twice, once in one edit box and again in another. So I created two edit boxes and then to each edit box added a control variable of type the custom edit box subclass I created. Now the problem is that when a enter a character in either of the edit boxes, the OnKeyDown function of the subclass …
Re: Subclassed Editbox Control: Do I need to create 2 subclasses for two edit controls?
Programming
Software Development
18 Years Ago
by BenPage
Hi Alvein I am not processing in the WndProc function where the HWND handle is passed as parameter. Lets say the class that I created, the custom edit box class, is called CMyEditControl. Then the function that I use to process the event that a key was pressed in the edit box looks like this: [code] void CMyEditControl::OnKeyDown(UINT …
Re: Subclassed Editbox Control: Do I need to create 2 subclasses for two edit controls?
Programming
Software Development
18 Years Ago
by Alvein
Thinkin aloud....is it possible to include a protected variable in your custom class, and initialize it accordingly in the constructor? that way you could simply check its value in the OnKeyDown() event.
Re: multiple subclasses. header files problem
Programming
Software Development
14 Years Ago
by Fbody
Are your header files macro-protected? [url=http://www.daniweb.com/forums/post1114822.html#post1114822]Clicky[/url]
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Forums
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC