Implement new Concept Exercise: classes
This issue describes how to implement the classes concept exercise for the F# track.
Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
The goal of this exercise is to teach the student the basics of the Concept of Classes in F#.
Learning objectives
- Know what classes are.
- Know what the difference is between classes and records and when to use which.
- Know what encapsulation is.
- Know what fields are.
- Know how to create an object.
- Know how to define methods.
Out of scope
- Static bindings.
- Mutable values.
- Properties.
- Composition.
- Additional constructors.
dobindings in classes.letandvalbindings in a class.- Interfaces.
- Inheritance.
- Properties.
- Indexers.
- Structs.
- Method overloading.
Concepts
The Concepts this exercise unlocks are:
classes: know what classes are; know what the difference is between classes and records and when to use which; know what encapsulation is; know what fields are; know how to create an bject; know how to define methods; know how to update state.
Prerequisites
This exercise's prerequisites Concepts are:
records: know what records are.tuples: know what tuples are (used for parameter passing).access-control: know about thepublicandprivateaccess controlunit: know about theunittype.
Any data types used in this exercise (e.g. strings or integers) should also be added as prerequisites.
Resources to refer to
Hints
- Classes: introduction to classes.
- Constructors: how to define primary and additional constructors, and how to create objects by calling a constructor.
- Methods: how to define methods in classes.
letbindings in classes: how to useletbindings to define fields.dobindings in classes: how to usedobindings to add constructor logic.valkeyword: describesvalfields.unit: describes theunittype.
After
- Classes: introduction to classes.
- Constructors: how to define primary and additional constructors, and how to create objects by calling a constructor.
- Methods: how to define methods in classes.
letbindings in classes: how to useletbindings to define fields.dobindings in classes: how to usedobindings to add constructor logic.valkeyword: describesvalfields.unit: describes theunittype.
Representer
This exercise does not require any specific representation logic to be added to the representer.
Analyzer
This exercise does not require any specific logic to be added to the analyzer.
Implementing
To implement this exercise, please follow these instructions.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.