Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You must design and develop a program in Java which follows the specification be

ID: 3877274 • Letter: Y

Question

You must design and develop a program in Java which follows the specification below.

Scenario

You have decided that it would be helpful to have a program on your laptop which helps you whilst at university. There are so many new ways of doing things and so many new ways of presenting information that a good computer program would be really useful. Since you are learning Java anyway, it seems sensible to use that.

Your program should allow you to take notes in lectures on a laptop and classify them by course and date. You should be able to search these notes for key words so that you can find the useful pieces of information.

Your program should also allow you to develop your coursework for each course. Here you should be able to add a course to your list of courses. Each course will have a coursework with a list requirements (things you are being asked to do) for that course. You should be able to add this list of requirements for each course. Finally, your program should allow you to add notes for each requirement.

Explanation / Answer

import java.util.Date;

public class Notes {

   String note;

   Date date;

  

   public Notes(String note) {

       this.note = note;

       date = new Date();

   }

   /**

   * @return the note

   */

   public String getNote() {

       return note;

   }

   /**

   * @param note the note to set

   */

   public void setNote(String note) {

       this.note = note;

   }

}

import java.util.ArrayList;

public class Requirements {

   //List of notes

   ArrayList<Notes> notes;

   String requirementName;

   public Requirements(String requirementName) {

       notes = new ArrayList<>();

       this.requirementName = requirementName;

   }

   //add notes

   public void addNotes(String note){

       notes.add(new Notes(note));

   }

   //search notes

   public ArrayList<String> searchKeyWords(String keywords){

       ArrayList<String> resultNotes = new ArrayList<>();

       //search in all notes using for loop and end into a list

       for(int i =0;i<notes.size();i++){

           if(notes.get(i).getNote().indexOf(keywords) != -1){

               resultNotes.add(notes.get(i).getNote());

           }

       }

       return resultNotes;

   }

  

}

import java.util.ArrayList;

public class CourseWork {

   //List of courseworks having requirements

   ArrayList<Requirements> requirements;

  

   //default constructor:intantiate list of coursework

   public CourseWork() {

       requirements = new ArrayList<>();

       }

  

   /**

   * @return the requirements

   */

   public ArrayList<Requirements> getRequirements() {

       return requirements;

   }

   /**

   * @param requirements the requirements to set

   */

   public void setRequirements(ArrayList<Requirements> requirements) {

       this.requirements = requirements;

   }

   //add coursework

   public void addRequirements(Requirements requirements){

       this.requirements.add(requirements);

   }

}

import java.util.ArrayList;

public class Course {

   private String CourseName;

   private CourseWork courseWork;

  

   /**

   * @param courseName

   * @param courseWork

   */

   public Course(String courseName, CourseWork courseWork) {

       super();

       CourseName = courseName;

       this.courseWork = courseWork;

   }

  

  

   /**

   * @return the courseName

   */

   public String getCourseName() {

       return CourseName;

   }

   /**

   * @param courseName the courseName to set

   */

   public void setCourseName(String courseName) {

       CourseName = courseName;

   }

   /**

   * @return the courseWork

   */

   public CourseWork getCourseWork() {

       return courseWork;

   }

   /**

   * @param courseWork the courseWork to set

   */

   public void setCourseWork(CourseWork courseWork) {

       this.courseWork = courseWork;

   }

   public static ArrayList<Course>courses = new ArrayList<>();

  

   public static void addCourse(Course course){

       courses.add(course);

   }

  

   public static void printCourseList(){

       if (!courses.isEmpty()){

       for(int i =0;i<courses.size();i++){

       System.out.println(courses.get(i).getCourseName());

       }

       }

   }

  

   public static ArrayList<String> searchNotes(String courseName,String keyword){

       ArrayList<String> result = new ArrayList<>();

       for(int i =0;i<courses.size();i++){

           if (courses.get(i).getCourseName().equalsIgnoreCase(courseName)){

               for(int j =0;j< courses.get(i).getCourseWork().getRequirements().size();j++){

                   result.addAll(courses.get(i).getCourseWork().getRequirements().get(j).searchKeyWords(keyword));

               }

           }

       }

       return result;

   }

   public static void main(String[] args) {

       CourseWork courseWork1= new CourseWork();

       Requirements requirement1= new Requirements("Thermodynamics");

       requirement1.addNotes("First law of Thermodynamics");

       requirement1.addNotes("Second law of Thermodynamics");

       requirement1.addNotes("Thermodynamics is a branch of physics concerned with heat and temperature and their relation to energy and work.");

      

       Requirements requirement2= new Requirements("Kinematics");

       requirement2.addNotes("Newton law of Motion");

       requirement2.addNotes("speed = distance/time");

  

       courseWork1.addRequirements(requirement1);

       courseWork1.addRequirements(requirement2);

       Course course1 = new Course("Physics",courseWork1);

      

       CourseWork courseWork2= new CourseWork();

       courseWork2.addRequirements(requirement1);

       Course course2 = new Course("Chemistry",courseWork2);

      

       Course.addCourse(course1);

       Course.addCourse(course2);

       Course.printCourseList();

      

       ArrayList<String> search =Course.searchNotes("Physics", "law of Thermodynamics");

       if (search.isEmpty())

           System.out.println("Notes not found");

       else{

           for(int i =0;i<search.size();i++){

               System.out.println(search.get(i));

           }

       }

      

      

   }

}

Sample output:

Physics

Chemistry

First law of Thermodynamics

Second law of Thermodynamics

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote