Need help,homework

Discussion in 'Java' started by theunknowable@lavabit.com, Dec 11, 2012.

  1. Guest

    Nooblet here, I need to write this application, I got as far as making 6
    empty classes and originally needed to use swing, though since I need to
    learn swing I may just make it a console application and get less points
    for it. I need to be able of writing to disk the data (utilizing user
    input), deleting it when I want too and show I understand how classes
    work. While I understand extends, I don't quite understand what implement
    does.

    Extends allows you to use the methods and variables of the class you
    extended (inheritance). Implement seems similar?

    Anyways, since I only have 1 day to do this and I've been trying to do
    this for weeks, what are the classes available that will allow me to:

    1.) Write a plain text file to disk?
    2.) read the file?
    3.) delete the file?
    4.) check for the existence of the file?
    5.) search for the file?
    6.) compare files?

    Where can I learn more about these specific classes? Any example code that
    is small and simple to read? :(
    , Dec 11, 2012
    #1
    1. Advertising

  2. Lew Guest

    wrote:
    > Nooblet here, I need to write this application, I got as far as making 6
    > empty classes and originally needed to use swing, though since I need to
    > learn swing I may just make it a console application and get less points
    > for it. I need to be able of writing to disk the data (utilizing user
    > input), deleting it when I want too and show I understand how classes
    > work. While I understand extends, I don't quite understand what implement
    > does.
    >
    > Extends allows you to use the methods and variables of the class you
    > extended (inheritance). Implement seems similar?


    'extends' is the keyword to inherit from a class, including implementation of methods.

    'implements' is the keyword for a _class_ to inherit from an interface, including only
    method signatures from the interface and leaving details of implementation entirely
    up to the implementing class.

    An interface can use 'extends' to inherit from another interface. Because an interface
    contains no implementation, it cannot 'implements' an interface.

    > Anyways, since I only have 1 day to do this and I've been trying to do


    You're going to have a hard time. Usenet isn't necessarily a one-day turnaround, and
    learning Java can take a few days.

    > this for weeks, what are the classes available that will allow me to:


    Tutorials and Javadocs.

    Tutorials:
    http://docs.oracle.com/javase/tutorial/

    Javadocs:
    http://docs.oracle.com/javase/7/docs/api/

    > 1.) Write a plain text file to disk?

    http://docs.oracle.com/javase/tutorial/essential/io/index.html
    http://docs.oracle.com/javase/7/docs/api/java/io/FileWriter.html

    > 2.) read the file?

    http://docs.oracle.com/javase/7/docs/api/java/io/FileReader.html

    > 3.) delete the file?

    http://docs.oracle.com/javase/7/docs/api/java/io/File.html

    > 4.) check for the existence of the file?

    http://docs.oracle.com/javase/7/docs/api/java/io/File.html

    > 5.) search for the file?

    http://docs.oracle.com/javase/7/docs/api/java/io/File.html
    plus
    http://docs.oracle.com/javase/7/docs/api/java/io/FileFilter.html
    plus
    http://docs.oracle.com/javase/7/docs/api/java/io/FilenameFilter.html
    plus glue code.

    > 6.) compare files?

    Read the files and compare contents. You'll need to be more specific about what you
    mean by "compare".

    > Where can I learn more about these specific classes? Any example code that
    > is small and simple to read? :(


    http://lmgtfy.com/?q=Java simple file I/O

    --
    Lew
    Lew, Dec 11, 2012
    #2
    1. Advertising

  3. Roedy Green Guest

    Roedy Green, Dec 12, 2012
    #3
  4. Lew Guest

    Roedy Green wrote:
    > theunknowable... wrote, quoted or indirectly quoted someone who said :
    >
    >> While I understand extends, I don't quite understand what implement
    >> does.

    >
    > see http://mindprod.com/jgloss/implements.html
    > http://mindprod.com/jgloss/class.html
    > http://mindprod.com/jgloss/interface.html


    OP, you'd be better off with the Oracle documentation and Google, whereby you
    can get more accurate and insightful information.

    Roedy is fond of driving traffic to his site from here. You might find something
    somewhat useful there, but you're far more likely to benefit from authoritative sources.

    --
    Lew
    Lew, Dec 12, 2012
    #4
  5. Arne Vajhøj Guest

    On 12/11/2012 9:37 PM, Roedy Green wrote:
    > On Tue, 11 Dec 2012 00:21:22 +0000 (UTC),
    > wrote, quoted or indirectly quoted someone who said :
    >> While I understand extends, I don't quite understand what implement
    >> does.

    >
    > see


    I am not sure that is good advice.

    > http://mindprod.com/jgloss/implements.html


    #implements is a keyword used on class or interface statements.

    class and interface are not statements.

    And an interface can not implements by definition.

    > http://mindprod.com/jgloss/class.html


    #Let’s say you had a TV class to deal with television sales. There are
    #two kinds of variables:
    #
    # static variables that track facts about all televisions in
    #general, e.g. total sold or a list of manufacturers.

    That sounds like an awful design to me.

    > http://mindprod.com/jgloss/interface.html


    #The throws clauses about Exceptions in the interface’s methods must
    #exactly match the throws clauses of the implementing methods.

    No.

    The implementing method can not throws an exception not in
    the interface, but it does not need to throws all exceptions
    in the interface.

    Arne
    Arne Vajhøj, Dec 13, 2012
    #5
  6. On 12/13/2012 02:42 AM, Arne Vajhøj wrote:
    > On 12/11/2012 9:37 PM, Roedy Green wrote:


    >> http://mindprod.com/jgloss/interface.html

    >
    > #The throws clauses about Exceptions in the interface’s methods must
    > #exactly match the throws clauses of the implementing methods.
    >
    > No.
    >
    > The implementing method can not throws an exception not in
    > the interface, but it does not need to throws all exceptions
    > in the interface.


    <nitpick>The implementing class can choose to declare a more restrictive
    throws clause, which means, sub classes of declared exceptions in the
    interface as well as a shorter throws clause. And it is allowed to
    throw all exceptions which are mentioned in the throws clause or sub
    classes of them.</nitpick>

    Kind regards

    robert
    Robert Klemme, Dec 14, 2012
    #6
  7. Arne Vajhøj Guest

    On 12/14/2012 2:03 AM, Robert Klemme wrote:
    > On 12/13/2012 02:42 AM, Arne Vajhøj wrote:
    >> On 12/11/2012 9:37 PM, Roedy Green wrote:

    >
    >>> http://mindprod.com/jgloss/interface.html

    >>
    >> #The throws clauses about Exceptions in the interface’s methods must
    >> #exactly match the throws clauses of the implementing methods.
    >>
    >> No.
    >>
    >> The implementing method can not throws an exception not in
    >> the interface, but it does not need to throws all exceptions
    >> in the interface.

    >
    > <nitpick>The implementing class can choose to declare a more restrictive
    > throws clause, which means, sub classes of declared exceptions in the
    > interface as well as a shorter throws clause. And it is allowed to
    > throw all exceptions which are mentioned in the throws clause or sub
    > classes of them.</nitpick>


    Good point.

    "not in the interface" must be "not instance of one in the
    interface" or "not assignable to one in the interface".

    Arne
    Arne Vajhøj, Dec 15, 2012
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    666
    Guest
    Feb 25, 2004
  2. Rhino

    need help with homework

    Rhino, Nov 16, 2003, in forum: Java
    Replies:
    1
    Views:
    300
    Roedy Green
    Nov 16, 2003
  3. Allens Mail

    Need Help On Homework

    Allens Mail, Jul 13, 2003, in forum: C++
    Replies:
    1
    Views:
    364
    Aggro
    Jul 14, 2003
  4. Mike
    Replies:
    1
    Views:
    320
    Phlip
    Nov 23, 2004
  5. Karl Heinz Buchegger

    Re: I need help with my homework!! Emergency!!!

    Karl Heinz Buchegger, Nov 23, 2004, in forum: C++
    Replies:
    1
    Views:
    379
    Raymond Martineau
    Nov 23, 2004
Loading...

Share This Page