Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package customer;
- /**
- *
- * @author hw003669
- */
- public class Customer {
- private String name;
- private Address homeAddress, workAddress;
- public String getName(){
- return this.name;
- }
- // public class Address {
- //
- // private int number;
- // private String street;
- //
- // public Address(int no, String street) {
- // number = no;
- // this.street = street;
- // }
- //
- // public String toString() {
- // return "the address of " + name + " is " + number + " " + street;
- // }
- // }
- // private class Address {
- //
- // private int number;
- // private String street;
- //
- // public Address(int no, String street) {
- // number = no;
- // this.street = street;
- // }
- //
- // public String toString() {
- // return "the address of " + name + " is " + number + " " + street;
- // }
- // }
- public static class Address {
- private int number;
- private String street;
- public Address(int no, String street) {
- number = no;
- this.street = street;
- }
- public String toString() {
- return "the address of " + name + " is " + number + " " + street;
- }
- // none static variable cannot be referenced from a static context
- }
- public Customer(String name, int houseNumber, String homeStreet) {
- this.name = name;
- homeAddress = new Address(houseNumber, homeStreet);
- }
- public String toString(){
- if (homeAddress == null){
- return "Home Address is null";
- }
- if (workAddress == null){
- return "work address is null";
- }
- return name + homeAddress + workAddress;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement