-4
/*
 * 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 addressname;

/**
 *
 * @author MY PC
 */
public class AddressName {

public static void main(String[] arg){
  
}

    private String name;
    private String streetAddress;
    private String city;
    private String state;
    private String zipCode;
    

    /**
     * Create an address with all empty fields.
     *
     */
    public AddressName ()
    {
        name = "";
        streetAddress = "";
        city = "";
        state = "";
        zipCode = "";
    }

    /**
     * Create an address.
     */
    public AddressName (String nm, String streetAddr, String city, 
            String state, String zip)
    {
        name = nm;
        streetAddress = streetAddr;
        this.city = city;
        this.state = state;
        zipCode = zip;
    }



    /**
     * @return the theName
     */
    public String getName() {
        return name;
    }

    /**
     * @param theName the theName to set
     */
    public void setName(String theName) {
        this.name = theName;
    }

    /**
     * @return the streetAddress
     */
    public String getStreetAddress() {
        return streetAddress;
    }

    /**
     * @param streetAddress the streetAddress to set
     */
    public void setStreetAddress(String streetAddress) {
        this.streetAddress = streetAddress;
    }

    /**
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * @return the state
     */
    public String getState() {
        return state;
    }

    /**
     * @param state the state to set
     */
    public void setState(String state) {
        this.state = state;
    }

    /**
     * @return the zipCode
     */
    public String getZipCode() {
        return zipCode;
    }

    /**
     * @param zipCode the zipCode to set
     */
    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    /**
     * True if the names and addresses are equal 
     */
    public boolean equals (Object right)
    {
        AddressName r = (AddressName)right;
        return name.equals(r.name)
                && streetAddress.equals(r.streetAddress)
                && city.equals(r.city)
                && state.equals(r.state)
                && zipCode.equals(r.zipCode);
    }

    public int hashCode ()
    {
        return name.hashCode() + 3 * streetAddress.hashCode()
        + 5 * city.hashCode()
        + 7 * state.hashCode()
        + 11 * zipCode.hashCode();
    }

    public String toString()
    {
        return name + ": " + streetAddress + ": " 
                + city + ", " + state + " " + zipCode;
    }

    public Object clone()
    {
        return new AddressName(name, streetAddress, city,
                state, zipCode);
    }
   
}

Output Complete successful

  • 2
    You have no code at all inside your main method. The main method is the entry point for when you run a program and if you don't have any instructions in there then nothing is all your program will do. If you want to create Objects, print information or do anything at all, you're gonna have to write code for that. – OH GOD SPIDERS Feb 23 '21 at 13:13
  • 2
    Please see: [Why is “Can someone help me?” not an actual question?](http://meta.stackoverflow.com/q/284236) – EJoshuaS - Stand with Ukraine Feb 23 '21 at 13:17
  • Also, please don't use IDE tags for general programming questions. – EJoshuaS - Stand with Ukraine Feb 23 '21 at 13:17

1 Answers1

0

Modify the body of the main method like this:

public static void main(String[] arg) {
   Address address = new Address("The Game", "Seventh street", "Generic Town", "State", "1234");
  
   System.out.println(address.toString());
}
SzaPe
  • 131
  • 1
  • 8