0

So, I've got to write an invoice for a video store that has a Customer class which takes six attributes, the customer name (string), the street address (string), the city(String), the state(string), the zip code(string), and the telephone number. I had to use a parameterized constructor that receives the attributes as parameters as well as provide getters and setters. I believe I did this correctly.

Next I had to make a Video class that had four attributes, the video name (string), the year the video was released(integer), the video copy number(integer), and the daily rental rate(double). I had to do a parameterized constructor and getters and setters for this as well.

The problems start on my Invoice class which is to represent the rental of a video to a given customer, it is not finished, but is supposed to have four attributes, the customer renting the video, the video being rented, the date it was rented(as a inputted string), and the daily rental rate(double). It was also supposed to have three methods, the subtotal, the tax and the total. My problem is I've got the preset methods for the customers and the videos setup, I just have no clue how to effectively use them in an if statement. I don't know what I would put in my fourth test class to allow this to work. I am all but lost at this point, any push in the right direction would be greatly appreciated. here are my classes.

Customer:

public class Customer {
private String customerName;
private String streetAddress;
private String custCity;
private String custState;
private String custZip;
private String custPhone;
public Customer(String customerName, String streetAddress, String custCity, String custState, String custZip,
        String custPhone) {
    super();
    this.customerName = customerName;
    this.streetAddress = streetAddress;
    this.custCity = custCity;
    this.custState = custState;
    this.custZip = custZip;
    this.custPhone = custPhone;
}
public String getCustomerName() {
    return customerName;
}
public void setCustomerName(String customerName) {
    this.customerName = customerName;
}
public String getStreetAddress() {
    return streetAddress;
}
public void setStreetAddress(String streetAddress) {
    this.streetAddress = streetAddress;
}
public String getCustCity() {
    return custCity;
}
public void setCustCity(String custCity) {
    this.custCity = custCity;
}
public String getCustState() {
    return custState;
}
public void setCustState(String custState) {
    this.custState = custState;
}
public String getCustZip() {
    return custZip;
}
public void setCustZip(String custZip) {
    this.custZip = custZip;
}
public String getCustPhone() {
    return custPhone;
}
public void setCustPhone(String custPhone) {
    this.custPhone = custPhone;
}



}

Video:

public class Video {
private String videoName;
private int videoYear;
private int copyNum;
private double rentalRate;
public Video(String videoName, int videoYear, int copyNum, double rentalRate) {
    super();
    this.videoName = videoName;
    this.videoYear = videoYear;
    this.copyNum = copyNum;
    this.rentalRate = rentalRate;
}
public String getVideoName() {
    return videoName;
}
public void setVideoName(String videoName) {
    this.videoName = videoName;
}
public int getVideoYear() {
    return videoYear;
}
public void setVideoYear(int videoYear) {
    this.videoYear = videoYear;
}
public int getCopyNum() {
    return copyNum;
}
public void setCopyNum(int copyNum) {
    this.copyNum = copyNum;
}
public double getRentalRate() {
    return rentalRate;
}
public void setRentalRate(double rentalRate) {
    this.rentalRate = rentalRate;
}

Invoice (incomplete) :

    import java.util.Scanner;

public class Invoice {
     public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    Customer Brandon = new Customer("Brandon James" , "112 Oak Street" 
        , "CityVille" , "Alabama" , "18229",
        "912-2248");

Customer Judy = new Customer("Judy Vermooth" , "8008 Ribbit Ln.",
        "Metropolis" , "Pennsylvania" , "24057", "241-8009");

Video Easter = new Video("Easter 2", 2002, 4, 2.49);

Video DareDevil3 = new Video ("Dare Devil 3", 2012, 2, 3.62);




if( Prog4.newRental = "Brandon"){
    Customer Brandon = newCust

}
}
}

Prog4(incomplete):

import java.util.*;

public class Prog4 {
private String newRental;
private String vidName;
private String rentalDate;
private String daysRented;

public static void main(String[] args){
Scanner in = new Scanner(System.in);


System.out.println("Enter Customer Name: ");
 String newRental = in.nextLine();

System.out.println("Enter Video Name: ");
String vidName = in.nextLine();

System.out.println("Enter Rental date in mm/dd/yyyy format: ");
String rentalDate = in.nextLine();

System.out.println("Enter Number of Days Rented");
int daysRented = in.nextInt();
}

public String getNewRental() {
    return newRental;
}

public void setNewRental(String newRental) {
    this.newRental = newRental;
}

public String getVidName() {
    return vidName;
}

public void setVidName(String vidName) {
    this.vidName = vidName;
}

public String getRentalDate() {
    return rentalDate;
}

public void setRentalDate(String rentalDate) {
    this.rentalDate = rentalDate;
}

public String getDaysRented() {
    return daysRented;
}

public void setDaysRented(String daysRented) {
    this.daysRented = daysRented;
}

}
theshu
  • 15
  • 6
  • You are learning object orientation, right? One way of structuring your classes is to have your Invoice class contain one Customer object and several (a list) of Video objects. You can then make methods to add/remove Videos and print/toString the invoice. – heniv181 Feb 29 '16 at 10:45
  • @heniv181 Yes, I am. How would I go about structuring something like that? Sorry, I'm still relatively new to this and I feel like I'm just missing something that will seem so simple after I get it – theshu Feb 29 '16 at 22:16

0 Answers0