Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: noob question on abstract classes

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default noob question on abstract classes

    Ok. I have an assignment for class. It should be simple. Except... I don't understand what the teacher is asking for.

    Here's the assignment, my question is posted below:

    /*Hallmark has asked you to implement a system for them so that
    * a user can choose from a list of available cards. There are
    * 9 cards to choose from: Christmas, Valentine's, Birthday, Get
    * well soon, Anniversary, New baby, Thank you, Congratulations,
    * and blank. Your program asks the user who the card is for and
    * who it is from. If it is a birthday card, it also asks how old
    * the recipient is. If it is a blank card it asks what personal
    * message the sender would like to include. If it is a Valentine's
    * day card it personalizes the card by adding XOs to the end of
    * the card (hugs and kisses) based on the length of the recipient's
    * name. Create the cards by extending an abstract class Card and
    * using an abstract method called makeCard that is defined for
    * each card.*/

    Why/how would I use an abstract method instead of a constructor? The professor said that the abstract method is supposed to call the constructor method, but than.... what is the return type? Something about this assignment just isn't clicking for me...

    any suggestions/explanations? Please no solutions...


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: noob question on abstract classes

    The question is essentially asking to write classes which follow what is called the "Template Design Pattern". It allows one to abstract an algorithm, where the abstract class provides the structure and subclasses implement the algorithm (through the implementation of the abstract methods). Google this phrase and you will pull up many upon many examples of this technique.

Similar Threads

  1. newbie question about Abstract methods
    By FailMouse in forum Java Theory & Questions
    Replies: 3
    Last Post: August 10th, 2010, 11:51 PM
  2. Java: interfaces and abstract classes
    By pinansonoyon in forum Object Oriented Programming
    Replies: 1
    Last Post: May 6th, 2010, 10:17 AM
  3. [SOLVED] Abstract Classes Help
    By SweetyStacey in forum Object Oriented Programming
    Replies: 10
    Last Post: May 6th, 2010, 06:15 AM
  4. A Question Regarding Abstract Classes & Packages
    By Kerubu in forum Object Oriented Programming
    Replies: 3
    Last Post: December 21st, 2009, 01:27 PM
  5. Java program with abstract class along with two subclasses
    By crazydeo in forum Collections and Generics
    Replies: 2
    Last Post: June 10th, 2008, 11:45 AM