Ad
  • Custom User Avatar

    Task

    Emulate a back ATM Machine and its features with a class.

    Requirements

    Default Settings: new ATM(usersArr) where usersArr is an array of users {username: username, password: password, money: money}

    >> atm = new ATM(users<arr)

    The class will also have the following methods :

    • Register : atm.register(username, password)

      This adds a new user to database with 0$ money, return 0 when done, return 1 when user already exists.

    • Login : atm.login(username, password)

      login a user to do action next, return 0 when done, return 1 when wrong username or wrong password are given

    • Logout : atm.logout():

      logout current user, return 0 when done, return 1 when user already logged out

    • Query Stat : ATM.query()

      query account status, return {money: money} when done, return 1 when user already logged out

    • Change Password : ATM.changePass(oldPass, newPass)

      change password, return 0 when done, return 1 when logged out, return 2 when wrong old password is given

    • Payment : ATM.pay(count, target)

      Payment to another user registered, return new money when done, return 1 when already logged out, return 2 when no enough money, return 3 when target user not exist

    Good luck :-P

  • Custom User Avatar

    What does this mean?

    Notice: if a couple is already giving birth to a piglet, skip it when it given birth to it

    I propose you use an AI tool to review your descriptions. Most of your sentences are a bit iffy.

  • Custom User Avatar

    yep, thanks for notice

    1. I will fix it
    2. It is clear, the sample test shouldn't be edit by trainer
    3. ATM in the ATM in real bank is login one account one time too (This is a single machine implementation, not a cluster)
    4. For really, i think it is not important, and also rewrite it needs many times, and it will make all the current solutions invaild it is a big revision, so, i will not ediy it
    5. For really, i think current random tests count is the nough, but types really is less, i will add more other type, but not many
  • Custom User Avatar
  • Custom User Avatar

    Hello,

    Lots of issues here... I confess I don't like the general idea in the first place ("yet another bank account problem :rolleyes:")

    • The description is messed up (bullet points not rendered properly)
    • It's neither specified nor tested if the original objects (given in th constructor) can/should be mutated, or if the internal state should be protected against mutation (which would be the way to go)
    • The general setup with only one user logged in at a time is... "unfrotunate", let's say. That's totally unrealistic.
    • The output format returning inconsistent types is also a bit unfortunate. Normally, I guess all outputs should be objects, and the error states would be {error: number}
    • The random tests are very far, far away from a proper coverage of the various scenarii

    Cheers

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The sample test has a syntax error

  • Custom User Avatar

    You can republish when you're ready to move this kata from a draft state back to a beta state.

    Just so we're clear: as long as pigs start to breed before they die (13 days for boars and 14 days for sows), they'll successfully breed a new piglet (and then immediately die)?

  • Custom User Avatar

    The two problems you wrote was all fixed just now

  • Custom User Avatar

    Thank for your notices, i will fix error you said, if you willing, you can help me make description more clear

  • Custom User Avatar
  • Custom User Avatar

    The description is lacking key details and is under-defined. For example, the mechanics for how breeding works isn't entirely clear. Can a boar be 12 days old and still breed with a sow (meaning the boar would technically die during the breeding process), or do we need to factor in the age of death of the pigs before breeding begins? The pig type upon breeding isn't entirely clear either. You say it alternates, but does that mean it alternates globally, or for each new batch of breeding?

  • Custom User Avatar

    sample tests are missing const {assert} = require('chai');

  • Custom User Avatar

    Fixed

  • Custom User Avatar

    no sample tests