Question
Please assist with design pattern needed for this task as per below feedback. Thank you for the submission, Phakamile; however, you still have not adequately
Please assist with design pattern needed for this task as per below feedback.
Thank you for the submission, Phakamile; however, you still have not adequately implemented one of the design patterns discussed in the task.
TASK
Compulsory Task 2 Follow these steps: Using one of the patterns described, write the code needed to create 3 student objects. Each student object should have a describe() method that returns a string that describes the student. Each student will be described using a full name and a student number. The rest of the description will be built up based on the students activity at HyperionDev. For example, the description should explain which Bootcamps the student has registered for and which level of the Bootcamp has been completed. Below is sample output: Student 1: Susan Smith: - Registered for the Software Engineering Bootcamp - Completed level 1 Student 2: Michael Jansen: - Registered for the Web Development Bootcamp - Completed level 1 - Completed level 2 - Completed level 3 - Registered for the Software Engineering Bootcamp Student 3: Saoirse Ronan - Registered for the Web Development Bootcamp - Completed level 1 - Completed level 2 - Completed level 3 - Registered for the Software Engineering Bootcamp - Completed level 1
MY CODE THAT NEEDS A PATTERN
//Class to represent a Student class Student { //declaring Student class variables int studentId, noOfCourses; String name; String[] courses; int[] courseLevels; /** * Student constructor to initialize the variables * studentId unique id for each student * name name of the student * noOfCourses number of courses registered by the student * courses names of the courses registered by the student * courseLevels levels completed in each course registered by the student */ Student(int studentId, String name, int noOfCourses, String[] courses, int[] courseLevels) { this.studentId = studentId; this.name = name; this.courses = new String[noOfCourses]; this.courseLevels = new int[noOfCourses]; for (int i = 0 ; i < noOfCourses; i ++) { this.courses[i] = courses[i]; this.courseLevels[i] = courseLevels[i]; } this.noOfCourses = noOfCourses; } // Method to display the details of the student public void describe() { System.out.println("Student " + this.studentId + ": " + name + ":"); for (int i = 0; i < this.noOfCourses; i ++) { System.out.println("- Registered for the " + this.courses[i]); for (int j = 0; j < this.courseLevels[i]; j++) { System.out.println("- Completed level " + (j + 1)); } } } } //Main class to create and display details of 3 student objects public class Main { public static void main(String[] args) { //initializing courses and course levels for 3 students String[] courses1 = new String[] {"Software Engineering"}; int[] courseLevels1 = new int[] {1}; String[] courses2 = new String[] {"Web Development", "Software Engineering"}; int[] courseLevels2 = new int[] {3,0}; String[] courses3 = new String[]{"Web Development", "Software Engineering"}; int[] courseLevels3 = new int[]{3,1}; //creating 3 student objects Student obj1 = new Student(1, "Susan Smith", courses1.length, courses1, courseLevels1); Student obj2 = new Student(2, "Michael Jansen", courses2.length, courses2, courseLevels2); Student obj3 = new Student(3, "Saoirse Ronan", courses3.length, courses3, courseLevels3); //calling describe method for each Student object obj1.describe(); obj2.describe(); obj3.describe(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started