Chapter5_1-ClassesAndObjectsInDepth

S gannouni dr a touir introduction to oop class course

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: Private attributes ClassName - studentName: String - courseCode: String public class Course { // Attributes private String studentName; private String courseCode ; // No method Members } Page 16 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP class Course { // Data Member private String studentName; private String courseCode ; } public class CourseRegistration { public static void main(String args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.courseCode= “CSC112“; course1.studentName= “Majed AlKebir“; //Create and assign values to course2 course2 = new Course( ); course2.courseCode= “CSC107“; course2.studentName= “Fahd AlAmri“; System.out.println(course1.studentName + " has the course “+ course1.courseCode); System.out.println(course2.studentName + " has the course “+ course2.courseCode); } } Page 17 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Accessibility Example … Service obj = new Service(); class Service { public int memberOne; private int memberTwo; public void doOne() { obj.memberOne = 10; … obj.memberTwo = 20; } private void doTwo() { obj.doOne(); … } obj.doTwo(); } … Client Page 18 Service Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online