Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aroTP1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
COUETOUX Basile
aroTP1
Commits
442bba34
Commit
442bba34
authored
2 years ago
by
couetoux.b
Browse files
Options
Downloads
Patches
Plain Diff
ajout capacité
parent
d5036747
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.idea/vcs.xml
+6
-0
6 additions, 0 deletions
.idea/vcs.xml
src/App.java
+2
-2
2 additions, 2 deletions
src/App.java
src/Backpack.java
+15
-0
15 additions, 0 deletions
src/Backpack.java
src/InstanceReader.java
+4
-3
4 additions, 3 deletions
src/InstanceReader.java
with
27 additions
and
5 deletions
.idea/vcs.xml
0 → 100644
+
6
−
0
View file @
442bba34
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/App.java
+
2
−
2
View file @
442bba34
...
...
@@ -2,7 +2,7 @@ import java.util.List;
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
List
<
Loot
>
loots
=
new
InstanceReader
().
read
(
"src/sac0"
);
System
.
out
.
println
(
loots
);
Backpack
backpack
=
new
InstanceReader
().
read
(
"src/sac0"
);
System
.
out
.
println
(
backpack
);
}
}
This diff is collapsed.
Click to expand it.
src/Backpack.java
0 → 100644
+
15
−
0
View file @
442bba34
import
java.util.List
;
public
class
Backpack
{
int
capacity
;
List
<
Loot
>
loots
;
public
Backpack
(
int
capacity
,
List
<
Loot
>
loots
)
{
this
.
capacity
=
capacity
;
this
.
loots
=
loots
;
}
public
String
toString
(){
return
capacity
+
"\n"
+
loots
;
}
}
This diff is collapsed.
Click to expand it.
src/InstanceReader.java
+
4
−
3
View file @
442bba34
...
...
@@ -6,12 +6,13 @@ import java.util.stream.Stream;
public
class
InstanceReader
{
List
<
Loot
>
read
(
String
filename
)
throws
Exception
{
Backpack
read
(
String
filename
)
throws
Exception
{
File
file
=
new
File
(
filename
);
List
<
Loot
>
loots
=
new
ArrayList
<>();
BufferedReader
buffer
=
new
BufferedReader
(
new
FileReader
(
file
));
buffer
.
readLine
();
int
capacity
=
Integer
.
decode
(
buffer
.
readLine
()
)
;
Stream
<
String
>
lines
=
buffer
.
lines
();
lines
.
forEach
(
s
->
{
String
[]
line
=
s
.
split
(
" "
);
loots
.
add
(
new
Loot
(
Integer
.
decode
(
line
[
0
]),
...
...
@@ -19,7 +20,7 @@ public class InstanceReader {
);
});
return
loots
;
return
new
Backpack
(
capacity
,
loots
)
;
}
...
...
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