Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev-oo-v2
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Malori Alvarez
dev-oo-v2
Commits
75288ab6
Commit
75288ab6
authored
2 months ago
by
Malori Alvarez
Browse files
Options
Downloads
Patches
Plain Diff
TP 5-6
parent
49cc8bd7
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/tp5/Book.java
+71
-0
71 additions, 0 deletions
src/tp5/Book.java
src/tp5/Library.java
+42
-0
42 additions, 0 deletions
src/tp5/Library.java
src/tp6/Company.java
+7
-0
7 additions, 0 deletions
src/tp6/Company.java
with
120 additions
and
0 deletions
src/tp5/Book.java
0 → 100644
+
71
−
0
View file @
75288ab6
package
tp5
;
public
class
Book
{
//attributs
private
String
code
;
private
final
String
TITLE
;
private
/*final*/
String
author
;
private
final
int
PUBLICATIONYEAR
;
//constructeurs
public
Book
(
String
code
,
String
title
,
String
author
,
int
publicationYear
){
this
.
code
=
code
;
this
.
TITLE
=
title
;
this
.
author
=
author
;
this
.
PUBLICATIONYEAR
=
publicationYear
;
}
//getters
public
String
getCode
()
{
return
code
;
}
public
String
getTITLE
()
{
return
TITLE
;
}
public
String
getAuthor
()
{
return
author
;
}
public
int
getPUBLICATIONYEAR
()
{
return
PUBLICATIONYEAR
;
}
//sept heure
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
void
setAuthor
(
String
author
)
{
this
.
author
=
author
;
}
//méthodes
public
String
toString
(){
return
this
.
code
.
toUpperCase
()
+
":"
+
this
.
TITLE
+
"->"
+
this
.
author
+
","
+
this
.
PUBLICATIONYEAR
;
}
public
boolean
equals
(
Object
other
){
if
(
this
==
other
)
return
true
;
if
(
this
==
null
)
return
false
;
//classe
if
(
this
.
getClass
()!=
other
.
getClass
()){
return
false
;}
Book
autreNomQueOther
=
(
Book
)
other
;
//primitifs
if
(
this
.
PUBLICATIONYEAR
!=
autreNomQueOther
.
PUBLICATIONYEAR
)
return
false
;
//objets
if
(
this
.
author
==
null
)
{
if
(
autreNomQueOther
.
author
!=
null
)
return
false
;}
else
if
(!
this
.
author
.
equals
(
autreNomQueOther
.
author
))
return
false
;
}
}
This diff is collapsed.
Click to expand it.
src/tp5/Library.java
0 → 100644
+
42
−
0
View file @
75288ab6
package
tp5
;
import
java.util.ArrayList
;
//shift alt O
public
class
Library
{
private
ArrayList
<
Book
>
catalog
;
public
Library
(){
this
.
catalog
=
new
ArrayList
<
Book
>();
}
public
void
useLibrary
(){
if
(
catalog
.
isEmpty
()){
}
else
{
}
}
public
Book
getBook
(
String
code
){
Book
res
=
null
;
for
(
int
i
=
0
;
i
<
catalog
.
size
();
i
++)
if
(
code
.
equals
(
catalog
.
get
(
i
).
getCode
())){
res
=
catalog
.
get
(
i
);
return
res
;
}
return
null
;
}
boolean
addBook
(
Book
b
){
for
(
int
i
=
0
;
i
<
catalog
.
size
();
i
++)
if
(
equals
(
b
,
catalog
.
get
(
i
),
b
)){
add
(
b
);
return
true
;
}
return
false
;
}
}
This diff is collapsed.
Click to expand it.
src/tp6/Company.java
0 → 100644
+
7
−
0
View file @
75288ab6
package
tp6
;
import
java.util.ArrayList
;
public
class
Company
{
private
ArrayList
<
Employee
>
staff
=
new
ArrayList
<>();
}
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