Results 1 to 5 of 5
Thread: Implementing Interface
- 12-06-2007, 12:44 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 70
- Rep Power
- 0
Implementing Interface
I have written following interface with 3 abstract methods. Now class implementing this interface have to overwrite all of these 3 methods.
I have a situation where one class should implement all of these 3 methods and other should only implement createSchema method. How this is possible using this interface.Java Code:public interface Mapper { public void createSchema(); public int getNoOfClasses(); public void setHost(String hostName); }
- 12-06-2007, 04:10 PM #2
Member
- Join Date
- Dec 2007
- Posts
- 5
- Rep Power
- 0
The other class should not implement this interface if it shouldn't implement all the functions. You could just put something like
depending on what is required. It might be better if you had two interfaces.Java Code:public int getNoOfClasses(){ }
- 12-06-2007, 09:09 PM #3
You must provide the method declaration for each method defined in the implemented interface. What you do in the method body is up to you.
In pseudo code:
Java Code:public interface Mapper { public void createSchema(); public int getNoOfClasses(); public void setHost(String hostName); } class NeedAllMethods implements Mapper { public void createSchema() { // implementation... } public int getNoOfClasses() { // implementation... return intValue; } public void setHost(String hostName) { // implementation... } } class NeedOnlyOne implements Mapper { public void createSchema() { // no-op okay } public int getNoOfClasses() { // no-op okay but you must // return an [i]int[/i] value. return 0; } public void setHost(String hostName) { // no-op okay } }
- 02-16-2010, 02:48 PM #4
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
Su internet aumentano i siti web di aste al ribasso .
“Si gioca con le aste al ribasso ”, attraverso il meccanismo dell asta al ribasso . È l’ultima intuitiva creazione scovata nell’infinito universo della rete. Sul portale www.bidmouse.com - www.bidsnake.com o ancora www.fourbid.com www.strikebid.com www.goldengavel.it , si può acquistare di tutto al prezzo più basso della rete con un’offerta bassa e soprattutto unica.
Il congegno è lineare e le transazioni sono assolutamente prive di pericoli. Nella vetrina di qualsiasi sito di aste al ribasso andando nelle “Aste Aperte” sono esposte le proposte commerciali, comprensive del reale valore, ed il tempo residuo stimato per lanciare l’offerta, naturalmente con le asta al ribasso .
Dopo aver scelto il prodotto (un week-end distensivo piuttosto che uno scooter, ma anche orologi, cellulari e televisioni), si punta sul prezzo esatto per assicurarselo: vince l’ asta al ribasso , l’utente che ha formulato l’offerta ad un prezzo inferiore e soprattutto unico.
Se infatti il prezzo prescelto è già opzionato aste al ribasso , le due offerte automaticamente decadono. Se due utenti, ad esempio, decidono di offrire dieci euro per un computer portatile asta al ribasso , entrambi vengono eliminati dal gioco, mentre se un terzo ne offre undici, ed è l’unico a presentare l’offerta più bassa, il computer portatile è venduto a soli undici euro.
Un gioco, che s’intreccia con la fortuna ed un software che garantisce efficienza, affidabilità e sicurezza aste al ribasso . Sono questi gli ingredienti principali di quest’ultima innovazione tecnologica: un vaso di terracotta che non vuol rompersi in mezzo a molti vasi di ferro asta al ribasso .
Molti di questi siti sono recensiti sulla directory di aste al ribasso , dove è possibile commentare, votare, cercare spiegazioni e trucchi per vincere in qualsiasi asta al ribasso
- 02-16-2010, 03:33 PM #5
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
This code would compile, but I don't think it's a very good programming practice, the purpose of interfaces is code that runs, even when you change the implementation, as long as it adherres to the interface. So making a class that doesn't make all the methods functional would be counter-intuitive, and possibly create a maintenance nightmare. Like the suggestion above, you should rather use 2 interfaces for this problem.
Similar Threads
-
Implementing an interface
By bugger in forum Advanced JavaReplies: 1Last Post: 01-09-2008, 01:35 PM -
Implementing Serializable interface
By javaplus in forum Advanced JavaReplies: 4Last Post: 12-18-2007, 12:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks