public tool public class tool private int level

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vel = 1; public int Level { ... } // public Tool() {} } public class Tool { private int level = 1; public int Level { ... } public Tool() {} public Tool(int level) { ... } } public class UseTool { public static void Main() { Tool x = new Tool(); // ok } } OOP(II) 1 - OOP(1) Recapped public class UseTool { public static void Main() { Tool x = new Tool(); // use default level, ok Tool y = new Tool(1); // set level = 1, ok } } 13 OOP(II) 1 - OOP(1) Recapped 14 Default Constructor public class Tool { private int level = 1; public int Level { ... } // public Tool() {} public Tool(int level) { ... } } public class UseTool { public static void Main() { Tool x = new Tool(); // use default level, error Tool y = new Tool(1); // set level = 1, ok } } OOP(II) 1 - OOP(1) Recapped 15 Leo Leung PDF created with pdfFactory trial version www.pdffactory.com 3...
View Full Document

This note was uploaded on 12/12/2013 for the course CIM 2578 taught by Professor Mr.pak-cheongleung,leo during the Spring '12 term at Hong Kong Institute of Vocational Education.

Ask a homework question - tutors are online