package org.example.oo;

import java.io.Serializable;

public class EntityX implements Serializable {
	static final long serialVersionUID = 1L;

	private String name;
	private int age;

	public EntityX() {
		// a Constructor initializes the fields
		name = "Jonathan";
		age = 30;
	}

	public EntityX(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
		// if I need rules about who can access this field
		// I add these rules to the get method
	}

	public void setName(String name) {
		if (name == null) {
			throw new IllegalArgumentException("name required");
		}
		if (name.isEmpty()) {
			throw new IllegalArgumentException("name required");
		}
		if (name.length() > 25) {
			throw new IllegalArgumentException("name is too long");
		}
		this.name = name;
		// if I need rules about who can update this field
		// I add these rules to the set method
        // I need to add the rules for content
		// to the set method
	}

	@Override
	public String toString() {
		return "EntityX [name=" + name + ", age=" + age + "]";
	}

	// then take a break until 10:20am

}
