jeudi 20 mai 2021

Creating 3 Student Objects with Description Methods using Design Pattern in Java

I am practicing design patterns and I cannot figure out how to structure my code for this question, could someone please help me?

I need to make the program below using one of the Design Patterns in this list:

  • Strategy Design Pattern
  • Decorator Design Pattern
  • Adapter Design Pattern
  • Factory Design Pattern
  • Singleton Design Pattern

QUESTION

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 student’s activity at university. For example, the description should explain which courses the student has registered for and which level of the course has been completed.

Below is sample output:

Student 1: Susan Smith:

  • Registered for the Software Engineering Bootcamp
  • Completed level 1

Student 2: Michael Jackson:

  • 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

What I Tried

I first started out with using the Factory Design pattern, but then I realized the Decorator Design Pattern would probably be better as you can easily change the information related to a student. (I could be wrong though.) I didn't get far with my code so I don't think that would be very helpful.

Aucun commentaire:

Enregistrer un commentaire