Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev-oo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Turpin
dev-oo
Commits
334a06aa
Commit
334a06aa
authored
11 months ago
by
Samuel Turpin
Browse files
Options
Downloads
Patches
Plain Diff
tpOO-04::exo-contrôle2
parent
854f6072
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tp04/PendingCaseQueue.java
+131
-0
131 additions, 0 deletions
src/tp04/PendingCaseQueue.java
src/tp04/UsePendingCaseQueue.java
+13
-2
13 additions, 2 deletions
src/tp04/UsePendingCaseQueue.java
with
144 additions
and
2 deletions
src/tp04/PendingCaseQueue.java
0 → 100644
+
131
−
0
View file @
334a06aa
package
tp04
;
import
tpOO.tp04.PendingCase
;
public
class
PendingCaseQueue
{
public
static
int
CAPACITY
=
10
;
private
int
idx
;
private
PendingCase
[]
tableur
;
public
PendingCaseQueue
()
{
this
.
tableur
=
new
PendingCase
[
CAPACITY
];
}
public
PendingCase
removeOne
()
{
PendingCase
pc
=
null
;
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
!=
null
)
{
this
.
tableur
[
i
]
=
pc
;
break
;
}
}
return
pc
;
}
public
void
clear
()
{
PendingCase
pc
=
null
;
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
!=
null
)
{
this
.
tableur
[
i
]
=
pc
;
}
}
}
public
void
cheating
(
PendingCase
another
,
int
position
)
{
if
(!
isFull
()
&&
this
.
tableur
[
position
]
==
null
)
{
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
==
another
)
{
this
.
tableur
[
i
]
=
null
;
break
;
}
}
this
.
tableur
[
position
]
=
another
;
}
}
public
double
getTotalAmount
()
{
double
db
=
0.0
;
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
!=
null
)
{
db
=
db
+
this
.
tableur
[
i
].
getAmount
();
}
}
return
db
;
}
public
void
addOne
(
PendingCase
other
)
{
if
(!
isFull
())
{
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
==
null
)
{
this
.
tableur
[
i
]
=
other
;
break
;
}
}
}
}
public
boolean
isEmpty
()
{
int
compteur
=
0
;
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
==
null
)
{
compteur
=
compteur
+
1
;
}
}
return
this
.
tableur
.
length
==
compteur
;
}
public
int
size
()
{
return
CAPACITY
;
}
public
boolean
isFull
()
{
int
compteur
=
0
;
for
(
int
i
=
0
;
i
<
this
.
tableur
.
length
;
i
++)
{
if
(
this
.
tableur
[
i
]
!=
null
)
{
compteur
=
compteur
+
1
;
}
}
return
CAPACITY
==
compteur
;
}
@Override
public
String
toString
()
{
String
str
=
""
;
for
(
int
i
=
0
;
i
<
CAPACITY
;
i
++)
{
if
(
this
.
tableur
[
i
]
!=
null
)
{
str
=
str
+
this
.
tableur
[
i
].
getCompany
()+
" "
;
}
}
return
str
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/tp04/UsePendingCaseQueue.java
+
13
−
2
View file @
334a06aa
package
tp04
;
import
tpOO.tp04.PendingCase
;
public
class
UsePendingCaseQueue
{
public
static
void
main
(
String
[]
args
)
{
/*
PendingCase pc1 = new PendingCase("Alice", "AAA", 1234.56);
PendingCase
pc1
=
new
PendingCase
(
"Alice"
,
"AAA"
,
1234.56
);
PendingCase
pc2
=
new
PendingCase
(
"Bruno"
,
"BBB"
,
0.42
);
PendingCase
pc3
=
new
PendingCase
(
"Chloé"
,
"CCC"
,
745.99
);
PendingCase
pc4
=
new
PendingCase
(
"Denis"
,
"DDD"
,
125.0
);
...
...
@@ -24,6 +26,15 @@ public class UsePendingCaseQueue {
pcq
.
addOne
(
pc1
);
System
.
out
.
println
(
"After addition of pc1: "
+
pcq
);
pcq
.
clear
();
System.out.println("After clearing: " + pcq);*/
//C PAS FINI MA COUILLE
System
.
out
.
println
(
"After clearing: "
+
pcq
);
pcq
.
addOne
(
pc1
);
pcq
.
addOne
(
pc4
);
pcq
.
addOne
(
pc3
);
System
.
out
.
println
(
"Ajout: "
+
pcq
);
pcq
.
removeOne
();
System
.
out
.
println
(
"Delete: "
+
pcq
);
pcq
.
cheating
(
pc3
,
0
);
System
.
out
.
println
(
"Cheat: "
+
pcq
);
System
.
out
.
println
(
"Total Amount: "
+
pcq
.
getTotalAmount
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment