Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pages
- {
- private int pages;
- public Pages()
- {
- pages = 0;
- }
- public Pages(int p)
- {
- pages = p;
- }
- public void print()
- {
- System.out.println("My nb of pages: " + pages);
- }
- public String toString()
- {
- return "My nb of pages is " + pages;
- }
- public boolean equals(Object o)
- {
- return (o instanceof Pages) && ((Pages)o).pages == pages;
- }
- }
- class PagesMain
- {
- public static void main(String[] args)
- {
- Pages p1 = new Pages(100);
- Pages p2 = new Pages(100);
- System.out.println(p1);
- System.out.println(p2);
- System.out.println(p1.equals(p2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement