Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Hallmark Problem [Please help]

$
0
0
Howdy friends;
I have another assignment that I could use some guidance on. Below I have provided the assignments, my questions, and my code so far.
The Assignment:

Quote

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 a blank card.
1) Your program should have at least 9 classes in it that inherit from the abstract card class. (1 for each type of card)
2) Your program should asks the user who the card is for and who it is from.
3) It should also ask them what type of card they would like to create, by giving the user a menu to choose from?
4) If it is a birthday card, it also asks how old the recipient is.
5) If it is a blank card then it asks what personal message the sender would like to include.
6) 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.
The card can be text base. It does not have to be done in a GUI, but it can be done with one if you choose.
Create the cards by extending an abstract class Card and using an abstract method called makeCard that is defined for each card.
The abstract class should look like this:
abstract class Card { String recipient, from; public abstract void makeCard(); }


My Questions:
1) Can I just put all of the classes in one file or do I need to make separate files?
~ this is what I mean: http://www.tutorialspoint.com/java/java_inheritance.htm
If I can, an explanation of some sort would greatly be expected, same for if I can not.
2) Would I customize the cards the way the instructions wanted in the switch statement or somewhere else?

My Code: (I just started, and was confused)
import java.util.*;
public class Hallmark
{
  static Scanner console = new Scanner(System.in);
  public static void main(String[] args)
  {
    //declare variables
    boolean isInt = true;
    int iUserInput;
    int iInputCounter = 1;
    
   //MakeCard userCard = new MakeCard();
    
//menu
    String sMenu = "Please select your card:" + 
      "\n\t1) Christmas" + 
      "\n\t2) Valentines" +
      "\n\t3) Birthday" +
      "\n\t4) Get well soon" +
      "\n\t5) Anniversary" +
      "\n\t6) New Baby" +
      "\n\t7) Thank You" +
      "\n\t8) Congratulations" + 
      "\n\t9) Blank Card\n";
    
    //print menu
    System.out.print(sMenu);
 
    //confirm input
    do
    {
      System.out.println("Please enter a valid choice");
      try
      {
        iUserInput = console.nextInt();
        if (iUserInput >= 0 && iUserInput <= 9)
        {
          iInputCounter--;
          switch(iUserInput)
          {
            case 1: System.out.println("c");
            break;
            
            case 2: System.out.println("v");
            break;
            
            case 3: System.out.println("b");
            break;
            
            case 4: System.out.println("g");
            break;
            
            case 5: System.out.println("a");
            break;
            
            case 6: System.out.println("n");
            break;
            
            case 7: System.out.println("t");
            break;
            
            case 8: System.out.println("co");
            break;
            
            case 9: System.out.println("bl");
            break;
            
            default: System.out.println("in");
            break;
          }
        }
        else
        {
          System.out.println("You have not entered a valid choice");
          continue;
        }
      }
      catch (InputMismatchException e)
      {
        System.out.println("You have entered an invalid input");
        console.next();
        continue;
      }
    }while(iInputCounter > 0);
  }
  // define Card class
  /*public abstract class Card
  {
    //initialize variables
    String sRecipient, sFrom;
    //method call
    public abstract void makeCard();
    */
}



Thank you for any suggestions.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>