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 4 of 4

Thread: Assignment - Question attached. not sure how to add customer class

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

    Default Assignment - Question attached. not sure how to add customer class

    this is the question.
    A customer has a name, an email address and a list of supplements which they are interested in.
    A paying customer has a payment method and a list of associate customers whom they also pay for.
    An associate customer is a customer whose subscription is paid for by a specified paying customer.
    A payment method could be by a specified credit card or direct debit from a specified bank account.
    A supplement has a name and a weekly cost.
    The magazine also has a weekly cost for the main part.
    Each week, each customer gets an email telling them their magazine is ready to look at and listing the supplements that they currently subscribe to.
    Each month, each paying customer gets an email telling them how much is being charged to their card or account for the month and itemizing the cost by supplements for them and any of their associate customers.
    Design and implement enough functionality in the classes to allow the operation of the following test program (which you also design, implement, test, and document):
    The client program should do the following:
    a) construct a magazine with an array of 3-4 supplements with made-up details built in to the program (Alternatively, get input from the user using the Java Scanner class),
    b) construct an array of 5-6 different customers of various types with made-up details built in to the program (Alternatively, get input from the user using the Java Scanner class),
    c) view details of all customers stored in the array,
    d) print out the text of all the emails for all customers for one week of magazines,
    e) print out the text for the end of month emails for the paying customers,
    f) add a new customer to the magazine service,
    g) remove an existing customer from the magazine service.
    Display enough information during the running of the program to allow checking of its operation.

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */

    package assignmentmag;

    import java.util.*;
    /**
    *
    * @author Matt Burdan
    * S.No: 32307288
    */
    public class AssignmentMag {

    public static void main(String[] args){

    //Make a new Magazine
    Magazine newMag = new Magazine();

    newMag.setTitle("Matts Test Magizine");
    System.out.println(newMag.getTitle());

    //Add some supplements using addSuppsToList
    addSuppsToMag(newMag);

    //View all the supplements briefly
    newMag.viewSuppsBrief();

    //View all the supplements in detail
    newMag.viewSupps();

    //View the supplement number i

    addCustomertomag(newMag);




    }

    //addSuppsToList(Magazine)
    //Adds various supplements to the magazine provided
    public static void addSuppsToMag(Magazine inMag){

    //Make a new supplement: Counterstrike
    Supplement testSupp = new Supplement();

    //Set its values
    testSupp.setSuppName("Counter-strike");
    testSupp.setSuppInfo("Subscribe to this supplement to get all the information "
    + "you could ever want to regarding Counterstrike!");
    testSupp.setSuppCost(6);

    //Add the supplement to the magazine
    inMag.addSupp(testSupp);

    //Make a new supplement: Titanfall
    Supplement testSupp2 = new Supplement("Titanfall", 6, "Subscribe to this "
    + "supplement to get all the information you could ever want to "
    + "regarding Titanfall!");

    //Add the supplement to the magazine
    inMag.addSupp(testSupp2);

    //Make a new supplement: Left for dead
    Supplement testSupp3 = new Supplement("Left for dead", 6, "Subscribe to this "
    + "supplement to get all the information you could ever want to "
    + "regarding Left for dead!");

    //Add the supplement to the magazine
    inMag.addSupp(testSupp3);

    //Make a new supplement: Halo
    Supplement testSupp4 = new Supplement("Halo", 6, "Subscribe to this "
    + "supplement to get all the information you could ever want to "
    + "regarding Halo!");

    //Add the supplement to the magazine
    inMag.addSupp(testSupp4);
    }
    public static void addCustomertomag(Magazine inMag){

    Customer testCust = new Customer();

    testCust.setCustname("MattB");
    testCust.setemail("matt_burdan@fakemail.com");
    testCust.setPaymentinfo("PayPal");

    inMag.addCust(testCust);

    Customer testCust2 = new Customer();

    testCust.setCustname("Josh");
    testCust.setemail("joshn@fakemail.com");
    testCust.setPaymentinfo("creditcard");

    inMag.addCust(testCust2);

    Customer testCust3 = new Customer();

    testCust.setCustname("Tim");
    testCust.setemail("timtam@fakemail.com");
    testCust.setPaymentinfo("debitcard");

    inMag.addCust(testCust3);

    Customer testCust4 = new Customer();

    testCust.setCustname("Aaron");
    testCust.setemail("aron@fakemail.com");
    testCust.setPaymentinfo("creditcard");

    inMag.addCust(testCust4);


    }

    }


    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */

    package assignmentmag;

    import java.util.*;

    /**
    *
    * @author MattBurdan
    */
    public class Magazine {

    //Declare class variables
    private String magTitle;
    private String weeklyNot;
    private String monthlyNot;
    private double costPerWeek;
    private double costPerMonth;
    private ArrayList<Supplement> supplements = new ArrayList();
    private int issueNo;

    //Mutator Functions

    //setTitle(String)
    //Sets the name of the title to the string provided
    public void setTitle(String inTitle){
    magTitle = inTitle;
    }

    //setWeeklyNot(String)
    //Sets the weekly notificcation to the string provided
    public void setWeeklyNot(String inNot){
    weeklyNot = inNot;
    }

    //setMontlyNot(String)
    //Sets the monthly notification to the string provided
    public void setMonthlyNot(String inNot){
    monthlyNot = inNot;
    }

    //setWeeklyCost(double)
    //Sets the weekly cost of the magazine to the value provided
    public void setWeeklyCost(double inCost){
    costPerWeek = inCost;
    }

    //setMonthlyCost(double)
    //Sets the monthly cost to the value provided
    public void setMonthlyCost(double inCost){
    costPerMonth = inCost;
    }


    //addSupplement(Supplement)
    //Adds the supplement provided to the list of supplements
    public void addSupp(Supplement inSupp){
    supplements.add(inSupp);
    }

    //delSupplement(Supplement)
    //Removes provided supplement from the list of supplements
    public void delSupp(Supplement inSupp){
    supplements.remove(inSupp);
    }

    //Accessor Functions

    //getTitle()
    //Returns the title of the magazine
    public String getTitle(){
    return magTitle;
    }

    //weeklyNotification()
    //Returns the weeklyNotification
    public String weeklyNotification(){
    return weeklyNot;
    }

    //monthlyNotification()
    //Returns the monthly notification
    public String monthlyNotification(){
    return monthlyNot;
    }

    //getWeeklyCost()
    //Returns the weekly cost of the magazine
    public double getWeeklyCost(){
    return costPerWeek;
    }

    //getMonthlyCost()
    //Returns the monthly cost of the magazine
    public double getMonthlyCost(){
    return costPerMonth;
    }

    public Supplement getSupplement(int i){
    Supplement result = new Supplement();
    //Make sure supplement list not emptyp
    if(!supplements.isEmpty())
    {
    if(i <= supplements.size())
    {
    result = supplements.get(i-1);
    }
    }
    return result;
    }


    //viewSuppsBrief()
    //Displays a brief list of the supplements available
    public void viewSuppsBrief(){
    //Check if supplement list is not empty
    if(!supplements.isEmpty())
    {
    System.out.println("Current Supplements");
    System.out.println("The current supplements are: " + supplements.size());
    System.out.println();
    for(int i = 0; i < supplements.size(); i++)
    {
    System.out.println("Number " + (i +1) +": " + supplements.get(i).getSuppName());
    System.out.println();
    }
    }
    }

    //viewSupps
    //Displays a listing of the current supplements available
    public void viewSupps(){
    //Display count of current supplements
    System.out.println("Current Supplements");
    System.out.println("The current supplements are: " + supplements.size());
    System.out.println();
    //Display information for each supplement
    for(int i = 0; i < supplements.size(); i++)
    {
    System.out.print("Cost of supplement: $");
    System.out.printf("%.2f\n", supplements.get(i).getSuppCost());
    System.out.println("Number " + (i + 1));
    System.out.println("Name of Supplement:" + supplements.get(i).getSuppName());
    System.out.println(supplements.get(i).getSuppInfo( ));
    System.out.println();
    }
    }

    //viewSupp(i)
    //Print out the details of the supplement at index i
    public void viewSupp(int i){
    //Make sure list is not empty
    if(!supplements.isEmpty())
    {
    if((i > 0) && (i <= supplements.size()))
    {
    System.out.print("Cost of supplement: $");
    System.out.printf("%.2f\n", supplements.get(i).getSuppCost());
    System.out.println("Number " + i);
    System.out.println("Name of Supplement:" + supplements.get(i-1).getSuppName());
    System.out.println(supplements.get(i-1).getSuppInfo());
    System.out.println();
    }
    }
    }
    }

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */

    package assignmentmag;

    /**
    *
    * @author MattBurdan
    */
    public class Supplement {
    //Declare Supplement Variables
    private String suppName; //Name of the supplement
    private double cost; //Cost of subscription
    private String info; //Brief description of supplement

    //Constructors

    //Supplement()
    //Creates a new supplement using default values
    Supplement(){
    suppName = "This field not yet set!";
    cost = 0.00;
    info = "This field not yet set!";
    }
    //Supplement(String, double, String)
    //Creates a new supplement and sets its name, cost and info to those
    //values supplied
    Supplement(String inName, double inCost, String inInfo){
    suppName = inName;
    cost = inCost;
    info = inInfo;
    }


    //Mutator functions

    //setSuppName(String)
    //Set the name of the supplement to supplied string
    public void setSuppName(String inName){
    suppName = inName;
    }

    //setSuppCost(double)
    //Sets the cost of the supplement to value provided
    public void setSuppCost(double inCost){
    cost = inCost;
    }

    //setSuppInfo(String)
    //Sets the info field to a brief description of supplement provided
    public void setSuppInfo(String inInfo){
    info = inInfo;
    }

    //Accessor functions

    //getSuppName()
    //Returns the name of the supplement
    public String getSuppName(){

    String value;

    //If suppName not yet set, return a message indicating such
    if(suppName.isEmpty())
    {
    value = "This field not set yet.";
    }
    else
    {
    value = suppName;
    }

    return value;
    }

    //getSuppCost()
    //Returns the cost of the supplement
    public double getSuppCost(){
    return this.cost;
    }

    //getSuppInfo()
    //Returns a brief description of the supplement
    public String getSuppInfo(){

    String value;

    //If info not yet set, return a message indicating such
    if(info.isEmpty())
    {
    value = "This field not set yet.";
    }
    else
    {
    value = info;
    }
    return value;
    }

    }
    Attached Files Attached Files
    Last edited by Mattz0r; June 24th, 2014 at 07:37 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Assignment - Problem written and Java code is in rar file attached

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Post your code directly in the post per the above link.
    i cannot get the customers to work and the rest that is needed.
    Define 'cannot . . work', ask specific questions.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Assignment - Question attached. not sure how to add customer class

    Also copy the text describing the assignment and paste it here. Not as a link to a pdf.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Assignment - Question attached. not sure how to add customer class

    I think you added the code since I first responded. Please post it correctly per the link I provided.

Similar Threads

  1. How to store zip or rar file into Oracle database in java
    By mr.spsonar in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 15th, 2014, 07:19 AM
  2. Help needed on basics of Methods- Written non written
    By eggpulusu in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 14th, 2013, 03:06 PM
  3. My AP CS Book Has Code Written in JRE5
    By RAWBERRY in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 24th, 2011, 07:55 PM
  4. Problem with code for school assignment?
    By Mellisa315 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 16th, 2010, 09:36 PM
  5. I NEED A WRITTEN CODE
    By samy222 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 22nd, 2010, 05:28 PM