Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Bassel Dib
Library
Commits
acce3cfa
Commit
acce3cfa
authored
11 months ago
by
Bassel Dib
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
16f42ee8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/example/Customer.java
+114
-0
114 additions, 0 deletions
src/main/java/org/example/Customer.java
with
114 additions
and
0 deletions
src/main/java/org/example/Customer.java
0 → 100644
+
114
−
0
View file @
acce3cfa
package
org.example
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Customer
{
private
String
name
;
private
String
adress
;
//different type?
private
String
email
;
private
List
<
Article
>
likedArticles
;
private
List
<
Book
>
likedBooks
;
private
List
<
Article
>
readArticles
;
private
List
<
Book
>
readBooks
;
private
int
bookLikesCount
;
private
int
articleLikesCount
;
private
int
articleReadCount
;
private
int
bookReadCount
;
//Constructer
public
Customer
(
String
name
,
String
address
,
String
email
)
{
this
.
name
=
name
;
this
.
adress
=
address
;
this
.
email
=
email
;
likedArticles
=
new
ArrayList
<>();
//make a list for every customer
likedBooks
=
new
ArrayList
<>();
readArticles
=
new
ArrayList
<>();
readBooks
=
new
ArrayList
<>();
bookLikesCount
=
0
;
bookReadCount
=
0
;
articleReadCount
=
0
;
articleLikesCount
=
0
;
}
/* make lists to add and store liked or read books and article and increase the number of likes/Read for that book */
public
void
likesArticle
(
Article
obj
){
likedArticles
.
add
(
obj
);
obj
.
increaseArticleLikes
(
obj
);
articleLikesCount
++;
}
public
void
likesBook
(
Book
obj
){
likedBooks
.
add
(
obj
);
obj
.
increaseBookLikes
(
obj
);
bookLikesCount
++;
//count of liked books per customer,, does it need to be static?, in this case it would be same num for all instances
}
public
void
readBook
(
Book
obj
){
readBooks
.
add
(
obj
);
obj
.
increaseBookRead
(
obj
);
bookReadCount
++;
}
public
void
readArticle
(
Article
obj
){
readArticles
.
add
(
obj
);
obj
.
increaseArticleRead
(
obj
);
articleReadCount
++;
}
/* return list with the like or read books and article from a customer instance */
public
List
<
Article
>
getLikedArticles
()
{
return
likedArticles
;
}
public
List
<
Book
>
getLikedBooks
()
{
return
likedBooks
;
}
public
List
<
Article
>
getReadArticles
()
{
return
readArticles
;
}
public
List
<
Book
>
getReadBooks
()
{
return
readBooks
;
}
public
int
getBookLikesCount
()
{
return
bookLikesCount
;
}
public
int
getArticleLikesCount
()
{
return
articleLikesCount
;
}
public
int
getArticleReadCount
()
{
return
articleReadCount
;
}
public
int
getBookReadCount
()
{
return
bookReadCount
;
}
@Override
public
String
toString
()
{
return
"Customer{"
+
" name='"
+
name
+
'\''
+
", adress='"
+
adress
+
'\''
+
", email='"
+
email
+
'}'
;
//+ '\'' +
// ", likedArticles=" + likedArticles +
// ", likedBooks=" + likedBooks +
//", readArticles=" + readArticles +
//", readBooks=" + readBooks +
//", bookLikesCount=" + bookLikesCount +
//'}';
}
public
String
getName
()
{
return
name
;
}
public
String
getAdress
()
{
return
adress
;
}
public
String
getEmail
()
{
return
email
;
}
}
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