Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

instatiate and process an array of objects

LUISLOP
LUISLOP 


GENERAL STEPS: ( see modifications that have to be done to this down below) Steps: define a new class called course.java with class atributtes as follow Atributtes: CourseId (String) courseTitle(String) creditHours(int) Constructors: the default constructor ( should be set courseId =" ", courseTitle = " ", creditHours = 0) the "init" constructor ( input parameters: courseId, courseTitle, creditHours) Write a test driver called testCourse.java that instatiates and array of Course objects with the following details: 1st element: courseId="CS101", courseTitle = " Introductory Computer science", credit hours = 3 2nd element: courseId = "CS102" , courseTitle = "Data Structures", creditHours=3 3rd element courseId="CS103", courseTItle="C++ Programing" , creditHours = 4. the test driver should then display the information on screen on the colums one for course, one for coursetitle and one for credit hours.. MODIFICATIONS THAT NEED TO BE DONE TO MAIN ASSIGMENT: -All the three attributes – courseId, courseTitle, and creditHours – must be declared by following the encapsulation principle. -For each of the three attributes, also write a getter and a setter method. -At least one of the setter method must use the " this" keyword in its method body. Attachments
Tags
Clarifications

Answers

Course Array Solution

Seeker
Seeker 



Java source code is attached Attachments
Course.zip (1 K) Download
Preview
add new Course to each member of the array courses[0] = new Course("CS101", "Introductory Computer Science", 3); courses[1] = new Course("CS102", "Data Structures", 3); courses[2] = new Course("CS103",

Preview
Course { private String courseId; private String courseTitle; private int creditHours; public Course(){ this.courseId = ""; this.courseTitle = ""; this.creditHours = 0; } public Course(String courseId, String courseTitle,

Screenshots
Purchase Answer

Assigment

mariobeka
mariobeka 



Attached you'll find the two java classes that you asked for. Attachments
Assigment.zip (4 K) Download





Preview
int creditHours; public Course() { courseId =""; courseTitle = ""; creditHours = 0; } public Course(String courseId, String courseTitle, int creditHours) { this.courseId = courseId; this.courseTitle =

Preview
course[] = new Course[] {new Course("CS101", "Introductory Computer science", 3), new Course("CS102", "Data Structures", 3), new Course("CS103", "C++ Programing", 4)};

Screenshots
Purchase Answer