Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
angel14995


Member


Joined: 13 Oct 2007
Posts: 181

Posted: 07 Dec 2008 02:08:30 pm    Post subject:

I'm currently working on a homework assignment for Computer Science (aka Java Programming), and what I need to do is reduce the visibility of an inherited method. I'm working with a pre-created platform, and in an class that inherits that platform, I need to reduce the visibility of a method so as to make the code a little safer. Anyone have any ideas? I've tried just overriding it, but with a private modifier instead of a public one, but that gives me errors. I'm trying not to edit the platform at all.

Any ideas?
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 07 Dec 2008 03:09:51 pm    Post subject:

Hmmm... Try doing protected. I don't think you will be able to make it "disappear" without changing the platform.

Last edited by Guest on 22 Jul 2010 11:13:08 am; edited 1 time in total
Back to top
bananaman
Indestructible


Calc Guru


Joined: 12 Sep 2005
Posts: 1124

Posted: 07 Dec 2008 03:15:37 pm    Post subject:

Protected should be the correct keyword that you are looking for. It is similar to private in that outside classes are not allowed to access the method, but the difference is that inherited classes are granted access to the method.
Back to top
Zaphod Beeblebrox


Member


Joined: 02 Jul 2007
Posts: 119

Posted: 07 Dec 2008 04:55:05 pm    Post subject:

If thats not what your looking for, you could use [font="Courier"]abstract in the method definition.

EDIT: Sorry, I meant to say [font="Courier"]final. Not [font="Courier"]abstract.

Last edited by Guest on 07 Dec 2008 04:59:56 pm; edited 1 time in total
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 08 Dec 2008 07:51:36 am    Post subject:

I don't think you can just override an inherited method with "protected"... Try calling the method from a private method of yours.

If the premade platform's method is not "protected" itself, it's just poorly designed Very Happy
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement