Try to search your question here, if you can't find : Ask Any Question Now ?

Creating Address Attribute in Java

HomeCategory: stackoverflowCreating Address Attribute in Java
Avatarjohn asked 4 months ago
package week3;

import java.util.ArrayList;

public abstract class TaxPayer {

private final String TFN;
private String firstName;
private String lastName;
private double income;

private Address address(int streetNumber, String streetName, String suburb,
        String city, String state, int postcode);

public TaxPayer(String TFN, String firstName, String lastName, double income,
        Address address) {
    this.TFN = TFN;
    this.firstName = firstName;
    this.lastName = lastName;
    this.income = income;
    this.address = address;
}

public String getFirstName() {
    return firstName;
}

public String getLastName() {
    return lastName;
}

public double getIncome() {
    return income;
}

public Address getAddress() {
    return address;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public void setIncome(double income) {
    this.income = income;
}

public void setAddress(Address i) {

}

public String getFullName() {
    return getFirstName() + " " + getLastName();
}

@Override
public String toString() {
    return TFN + " " + firstName + " " + lastName + " "
            + income;
}

public static double calcTax(double income) {
    return 1;
}

public double calcTax() {
    return 1;
}

public static void printArrayListToConsole(ArrayList<TaxPayer> Array) {
    for (TaxPayer d : Array) {
        System.out.println(d);
    }
}

}

package week3;

public class Address {

int streetNumber;
String streetName;
String suburb;
String city;
String state;
int postcode;

public Address(int streetNumber, String streetName, String suburb,
        String city, String state, int postcode) {

    this.streetNumber = streetNumber;
    this.streetName = streetName;
    this.suburb = suburb;
    this.city = city;
    this.state = state;
    this.postcode = postcode;
}

@Override
public String toString() {
    return streetNumber + " " + streetName + " " + suburb + " " + city + " "
            + state + " " + postcode;
}

}
So my problem is in creating the address attribute, which must be private. I think I’ve made the other class correctly yet it still isn’t working. As well as this, the attribute isn’t working with the fields I try to put in it (streetNumber, streetName, etc), it’s coming up with the error ‘missing method body, or declare abstract’ but I’m unsure why. Any help is appreciated!

1 Answers
Best Answer
AvatarAmit answered 4 months ago
Your Answer

11 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com