Question: Need to create testing code using vitetest for following: Model Class ( Model . ts ) export class Model { board: string [ ] [
Need to create testing code using vitetest for following:
Model Class Modelts
export class Model
board: string;
initialBoard: string;
swaps: number;
score: number;
constructorinitialConfig: string
this.initialBoard JSON.parseJSONstringifyinitialConfig; Deep copy of initial config
this.board JSON.parseJSONstringifyinitialConfig;
this.swaps ;
this.score ;
getBoard: string
return this.board;
getSwaps: number
return this.swaps;
getScore: number
return this.score;
reset: void
this.board JSON.parseJSONstringifythisinitialBoard;
this.swaps ;
this.score ;
swapSyllablesrow: number, col: number, row: number, col: number: void
const temp this.boardrowcol;
this.boardrowcol this.boardrowcol;
this.boardrowcol temp;
this.swaps;
this.updateScore;
undoSwappreviousBoard: string previousSwaps: number, previousScore: number: void
this.board previousBoard;
this.swaps previousSwaps;
this.score previousScore;
private updateScore: void
this.score ; Update this with your score logic
isSolved: boolean
Compare board state with the correct solution
return false;
Puzzle Classpuzzlets
export class Puzzle
static configurations: string
in "vis", i "ble"
im "mac", u "late"
af "fil", i "ate"
un "der", wa "ter"
examin "ing"
rein "force", "ment"
in "for", ma "tive"
material
me "chan", i "cal"
calcu "lat", "ing"
immedi "ate"
diagonal
;
Controller calsscontrollerts
import Model from model;
export class Controller
model: Model;
previousBoards: string;
previousSwaps: number;
previousScores: number;
constructormodel: Model
this.model model;
getBoard: string
return this.model.getBoard;
getSwaps: number
return this.model.getSwaps;
getScore: number
return this.model.getScore;
swapSyllablesrow: number, col: number, row: number, col: number: void
this.saveState; Save the current state before swap
this.model.swapSyllablesrow col row col;
reset: void
this.model.reset;
this.previousBoards ;
this.previousSwaps ;
this.previousScores ;
undo: void
if thispreviousBoards.length
const lastBoard this.previousBoards.pop;
const lastSwaps this.previousSwaps.pop;
const lastScore this.previousScores.pop;
this.model.undoSwaplastBoard lastSwaps, lastScore;
saveState: void
const boardCopy JSON.parseJSONstringifythismodel.getBoard;
this.previousBoards.pushboardCopy;
this.previousSwaps.pushthismodel.getSwaps;
this.previousScores.pushthismodel.getScore;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
