Update(Tp2): Correction apporter

pull/3/head
Louis DUFOUR 2 years ago
parent ddff922a5e
commit 8e178e86b1

@ -58,7 +58,7 @@ let initialBoardConfiguration: [[Cell]] = [
if let board = Board(withGrid: initialBoardConfiguration) {
// Afficher le plateau de jeu
print(board.display())
print(board)
} else {
print("Erreur lors de l'initialisation du plateau de jeu.")
}
@ -66,7 +66,7 @@ if let board = Board(withGrid: initialBoardConfiguration) {
// Initialisez un Board avec cette configuration
if var board = Board(withGrid: initialBoardConfiguration) {
print("Plateau initial:")
print(board.description) // Affichez l'état initial du plateau
print(board) // Affichez l'état initial du plateau
// Testez countPieces(of:)
let player1PieceCount = board.countPieces(of: .player1)
@ -82,12 +82,12 @@ if var board = Board(withGrid: initialBoardConfiguration) {
// Testez removePiece(atRow:andColumn:)
let removeResult = board.removePiece(atRow: 0, andColumn: 0)
print("Résultat de la suppression : \(removeResult)")
print(board.description) // Affichez le plateau après suppression
print(board) // Affichez le plateau après suppression
// Testez insert(piece:atRow:andColumn:)
let insertResult = board.insert(piece: Piece(withOwner: .player1, andAnimal: .lion), atRow: 0, andColumn: 0)
print("Résultat de l'insertion : \(insertResult)")
print(board.description) // Affichez le plateau après insertion
print(board) // Affichez le plateau après insertion
} else {
print("Erreur lors de l'initialisation du plateau de jeu.")
}

@ -9,16 +9,20 @@ import Foundation
import Model
public extension Board {
func display() {
extension Board: CustomStringConvertible {
public var description: String {
var description = ""
for row in grid {
for cell in row {
if let piece = cell.piece {
print(cell.cellType.symbol + piece.owner.symbol + piece.animal.symbol, terminator: " ")}
description += cell.cellType.symbol + piece.owner.symbol + piece.animal.symbol + " "}
else {
print(cell.cellType.symbol, terminator: " ")}
description += cell.cellType.symbol + " "}
}
print()
description += "\n"
}
return description
}
}

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Model"
BuildableName = "Model"
BlueprintName = "Model"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ModelTests"
BuildableName = "ModelTests"
BlueprintName = "ModelTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Model"
BuildableName = "Model"
BlueprintName = "Model"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Tests/ModelTests/ModelTests copy.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ModelTests"
BuildableName = "ModelTests"
BlueprintName = "ModelTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -7,7 +7,7 @@
import Foundation
public enum Animal: String { case rat, cat, dog, wolf, leopard, tiger, lion, elephant
public enum Animal : CustomStringConvertible { case rat, cat, dog, wolf, leopard, tiger, lion, elephant
public var description: String {
switch self {

@ -7,10 +7,10 @@
import Foundation
public struct Board {
let nbRows: Int
let nbColumns: Int
public var grid: [[Cell]]
public struct Board : CustomStringConvertible {
public let nbRows: Int
public let nbColumns: Int
public private(set) var grid: [[Cell]]
public init?(withGrid grid: [[Cell]]) {
guard let firstRowLength = grid.first?.count, grid.allSatisfy({ $0.count == firstRowLength }) else {

@ -7,7 +7,7 @@
import Foundation
public struct Cell {
public struct Cell : CustomStringConvertible {
public let cellType: CellType
public var initialOwner: Owner
public var piece: Piece?

@ -7,7 +7,7 @@
import Foundation
public enum CellType {
public enum CellType : CustomStringConvertible {
case unknown, jungle, water, trap, den
public var description: String {

@ -7,7 +7,7 @@
import Foundation
public enum Owner {
public enum Owner : CustomStringConvertible {
case noOne, player1, player2
public var description: String {

@ -7,7 +7,7 @@
import Foundation
public struct Piece {
public struct Piece : CustomStringConvertible{
public let owner: Owner
public let animal: Animal

@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "FDE4F17C-2211-4B72-BFD6-0E54DA99D1CC",
"name" : "Configuration 1",
"options" : {
}
}
],
"defaultOptions" : {
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "ModelTests",
"name" : "ModelTests"
}
}
],
"version" : 1
}

@ -4,6 +4,9 @@
## Introduction
Le projet DouShouQi en Swift est une implémentation console du jeu de plateau DouShouQi.
## Correction
Le commit à prendre en compte pour ce Tp2 est celui à 15:33
## Prérequis
- **Système d'exploitation**: macOS Ventura 13.1
- **Logiciel**: Xcode version 14.2

Loading…
Cancel
Save