This repository was archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
My design #2
Open
rkyadaviitkgp
wants to merge
1
commit into
workattech:master
Choose a base branch
from
rkyadaviitkgp:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
My design #2
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package mock.machine.coding.pkg3; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * | ||
| * @author rajeshkumar.yadav | ||
| */ | ||
| public class Board extends Item{ | ||
|
|
||
| //Board: Each board should have a id, name, privacy (PUBLIC/PRIVATE), url, members, lists | ||
|
|
||
| private Privacy privacy; | ||
| private String url; | ||
| private List<User> userList; | ||
| private List<ListItem> list; | ||
|
|
||
| public Board(Privacy privacy, String name) { | ||
|
|
||
| super(name); | ||
| this.privacy = privacy; | ||
| url = URLGenerator.getURL(getId()); | ||
| userList = new ArrayList<>(); | ||
| list = new ArrayList<>(); | ||
| } | ||
|
|
||
| public Privacy getPrivacy() { | ||
| return privacy; | ||
| } | ||
|
|
||
| public String getUrl() { | ||
| return url; | ||
| } | ||
|
|
||
| public void setPrivacy(Privacy privacy) { | ||
| this.privacy = privacy; | ||
| } | ||
|
|
||
| public void setUrl(String url) { | ||
| this.url = url; | ||
| } | ||
|
|
||
| public void addListItemToBoard(ListItem l){ | ||
| list.add(l); | ||
| l.setBoard(this); | ||
| } | ||
|
|
||
| public void removeListFromBoard(ListItem l){ | ||
| if(list.contains(l)) | ||
| list.remove(l); | ||
| } | ||
|
|
||
| public void addUserToBoard(User u){ | ||
| userList.add(u); | ||
| } | ||
|
|
||
| public void removeUserToBoard(User u){ | ||
| if(userList.contains(u)) | ||
| userList.remove(u); | ||
| } | ||
|
|
||
| public String getPrintableString(){ | ||
| String s = "{ Id: " + getId() + ", Name: " + getName() + " privacy: " + getPrivacy() + ", URL: " + getUrl(); | ||
| if(userList.size() > 0){ | ||
| s = s + ", Users: ["; | ||
| for(int i=0; i<userList.size(); i++){ | ||
| s = s + userList.get(i).getPrintableString(); | ||
| if(i<userList.size()-1) | ||
| s = s+", "; | ||
| } | ||
| s = s + "]"; | ||
| } | ||
| if(list.size() > 0){ | ||
| s = s + ", List: ["; | ||
| for(int i=0; i<list.size(); i++){ | ||
| s = s + list.get(i).getPrintableString(); | ||
| if(i<list.size()-1) | ||
| s = s+", "; | ||
| } | ||
| s = s + "]"; | ||
| } | ||
| s = s + " }"; | ||
| return s; | ||
| } | ||
|
|
||
| public void show(){ | ||
| System.out.println(getPrintableString()); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package mock.machine.coding.pkg3; | ||
|
|
||
| /** | ||
| * | ||
| * @author rajeshkumar.yadav | ||
| */ | ||
| public class Card extends Item{ | ||
|
|
||
| //Card: Each card should have a id, name, description, assigned user | ||
| private String description; | ||
| private User assigendUser; | ||
| private ListItem litem; | ||
|
|
||
| public Card(String name) { | ||
| super(name); | ||
| //this.assigendUser = assigendUser; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public User getAssigendUser() { | ||
| return assigendUser; | ||
| } | ||
|
|
||
| public void setAssigendUser(User assigendUser) { | ||
| this.assigendUser = assigendUser; | ||
| } | ||
|
|
||
| public void unAssigendUser() { | ||
| this.assigendUser = null; | ||
| } | ||
|
|
||
| public ListItem getLitem() { | ||
| return litem; | ||
| } | ||
|
|
||
| public void setLitem(ListItem litem) { | ||
| this.litem = litem; | ||
| } | ||
|
|
||
| public String getPrintableString(){ | ||
| String s = " { id: " + getId() + ", name: " + getName() + ", description: " + getDescription() + ", AssignedToUser: " + getAssigendUser().getName() + " }"; | ||
| return s; | ||
| } | ||
|
|
||
| public void show(){ | ||
| System.out.println(getPrintableString()); | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package mock.machine.coding.pkg3; | ||
|
|
||
| /** | ||
| * | ||
| * @author rajeshkumar.yadav | ||
| */ | ||
| public class IdCreator { | ||
|
|
||
| private static int inc = 0; | ||
| private static IdCreator idCreator = null; | ||
|
|
||
| private IdCreator(){ | ||
|
|
||
| } | ||
|
|
||
| public static IdCreator getInstance(){ | ||
| if(idCreator == null) | ||
| idCreator = new IdCreator(); | ||
| return idCreator; | ||
| } | ||
|
|
||
| public static String getNewId(){ | ||
|
|
||
| String s = String.valueOf(System.currentTimeMillis()).substring(1,9); | ||
| inc = (inc + 1)%10; | ||
| s = s + inc; | ||
| return s; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package mock.machine.coding.pkg3; | ||
|
|
||
| /** | ||
| * | ||
| * @author rajeshkumar.yadav | ||
| */ | ||
| public class Item { | ||
|
|
||
| private String id; | ||
| private String name; | ||
|
|
||
| public Item(String name) { | ||
| this.id = IdCreator.getNewId(); | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public void show(){ | ||
|
|
||
| } | ||
| public String getPrintableString(){ | ||
| return ""; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package mock.machine.coding.pkg3; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * | ||
| * @author rajeshkumar.yadav | ||
| */ | ||
| public class ListItem extends Item{ | ||
|
|
||
| // List: Each list should have a id, name and cards | ||
| private List<Card> cards; | ||
| private Board board; | ||
|
|
||
| public ListItem(String name) { | ||
| super(name); | ||
| cards = new ArrayList<>(); | ||
| } | ||
|
|
||
| public List<Card> getCards() { | ||
| return cards; | ||
| } | ||
|
|
||
| //We should also be able to move cards across lists in the same board | ||
| public void AddCardToList(Card c){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. camelCase? |
||
| if(c.getLitem() != null && this.getBoard() != c.getLitem().getBoard()) | ||
| return; | ||
| cards.add(c); | ||
| c.setLitem(this); | ||
| } | ||
|
|
||
| // We should also be able to remove cards from lists | ||
| public void removeCardFromList(Card c){ | ||
| if(c.getLitem() != null) | ||
| return; | ||
| cards.remove(c); | ||
| c.setLitem(null); | ||
| } | ||
|
|
||
| public Board getBoard() { | ||
| return board; | ||
| } | ||
|
|
||
| public void setBoard(Board board) { | ||
| this.board = board; | ||
| } | ||
|
|
||
| public String getPrintableString(){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be done by overriding toString |
||
| String s = "{ Id: " + getId() + ", Name: " + getName(); | ||
| if(cards.size() > 0){ | ||
| s = s + ", cards: ["; | ||
| for(int i=0; i<cards.size(); i++){ | ||
| s = s + cards.get(i).getPrintableString(); | ||
| if(i<cards.size()-1) | ||
| s = s+", "; | ||
| } | ||
| } | ||
| return s; | ||
| } | ||
|
|
||
| public void show(){ | ||
| System.out.println(getPrintableString()); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does ListItem have access to the Board?