Code Monkey home page Code Monkey logo

cpe200-week3-hw's Introduction

Week 3 - Homework: Students and Courses

This homework will help you learn how to write Java classes according to the specification.

The objectives of this week are following:

  • Programming abstraction (i.e., the Student and Course classes).
  • Overloading constructor.
  • Identify public and private interfaces.
  • Simple Data encapsulation and data validation.
  • Simple string matching using regular expression.
  • Overriding the toString() method.

To complete the homework you need to meet following requirements:

  • Write the Student and Course Java classes according the specifications.
  • Write a readable, sensible, usable, beautiful code.
  • Pass all the unit tests.

##Student Class Attributes:

  • Name : name of a student, CANNOT be empty (""), default value is "John Doe"
  • Student ID : student id number, default value is "560610000", MUST be in the pattern of "5X061PNNN" where ...
    • X is a number in [6-9]
    • P is a number in [0-2]
    • N is a number in [0-9]
  • Year of birth : birth year of a student, Must be larger than 1989, default value is "1990", will be used to calculate student's age later
  • Status : status of a student, can be "true" for active or "false" for inactive

Methods:

  • Default constructor : takes NO argument, initializes all attributes to their DEFAULT value.
  • Constructor2 : takes Name and Student ID as arguments, initializes the other attributes to their DEFAULT value.
  • Constructor3 : takes Name, Student ID and Year of birth as arguments, initializes the other attributes to their DEFAULT value.
  • Constructor4 : takes Name, Student ID, Year of birth and status as arguments, initializes the other attributes to their DEFAULT value.
  • Set Methods : for modifying value of each property (4 methods)
    • Set methods for Name, Student ID and Year of birth attributes MUST satisfy the conditions specified above.
    • if the modified (new) value does not satisfy with the above conditions, use the CURRENT value.
  • Get Methods : for reading value of each property (4 methods)
  • toString() method : for printing the student object's state which returns a string in the following pattern:
      "Sanguan Sornjai (590611702) was born in 1999 is an INACTIVE student."

##Course Class Attributes:

  • Course name : name of the course, CANNOT be empty (""), default value is "TBA"
  • Course ID : course id number, default value is "000000", MUST be in the pattern of "NNNNNN" where ...
    • N is a number in [0-9]
  • Lecturer : name of lecturer(s), CANNOT be empty (""), default value is "TBA"
  • Maximum #Student : maximum number of students, CANNOT be less than 10, default value is 30
  • Current #Student : current number of students, MUST be in the range of [0-MAX], default value is 0

Methods:

  • Default constructor : takes NO argument, initializes all attributes to their DEFAULT value.
  • Constructor2 : takes Course name and Course ID as arguments, initializes the other attributes to their DEFAULT value.
  • Constructor3 : takes Course name, Course ID and Lecturer as arguments, initializes the other attributes to their DEFAULT value.
  • Constructor4 : takes Course name, Course ID, Lecturer and Max #Student as arguments, initializes the other attributes to their DEFAULT value.
  • Set Methods : for modifying value of each property (5 methods)
    • Set methods for all attributes MUST satisfy the conditions specified above.
    • if the modified (new) value does not satisfy with the above conditions, use the CURRENT value.
  • Get Methods : for reading value of each property (5 methods)
  • toString() method : for printing the class object's state which returns a string in the following pattern:
      "CPE200-OOP (261200), Teacher: Pruet Boonma, has ONE student, [maximum: 60]"

###Note: You can match a string to a specified pattern using regular expression. Find more detail on the topic here: http://www.tutorialspoint.com/java/java_regular_expressions.htm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.