Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
HW-3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731029
HW-3
Commits
e4b85bb3
Commit
e4b85bb3
authored
Apr 11, 2019
by
amirhasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrected
parent
a086d581
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
190 additions
and
107 deletions
+190
-107
encodings.xml
.idea/encodings.xml
+4
-0
misc.xml
.idea/misc.xml
+1
-1
workspace.xml
.idea/workspace.xml
+47
-12
Shop$1.class
out/production/untitled/Shop$1.class
+0
-0
Shop$Customer.class
out/production/untitled/Shop$Customer.class
+0
-0
Shop$Discount.class
out/production/untitled/Shop$Discount.class
+0
-0
Shop$Good.class
out/production/untitled/Shop$Good.class
+0
-0
Shop$Order.class
out/production/untitled/Shop$Order.class
+0
-0
Shop$Repository.class
out/production/untitled/Shop$Repository.class
+0
-0
Shop.class
out/production/untitled/Shop.class
+0
-0
Shop.java
src/Shop.java
+138
-94
No files found.
.idea/encodings.xml
0 → 100644
View file @
e4b85bb3
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"Encoding"
addBOMForNewFiles=
"with NO BOM"
/>
</project>
\ No newline at end of file
.idea/misc.xml
View file @
e4b85bb3
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
_8"
default=
"true"
project-jdk-name=
"1.8
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
0"
default=
"true"
project-jdk-name=
"10.0.2+13
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
.idea/workspace.xml
View file @
e4b85bb3
...
...
@@ -2,6 +2,15 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"67bfc981-7b10-4bf4-963c-b8f3544bb91a"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/misc.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/misc.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$1.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$Customer.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$Discount.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$Good.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$Order.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop$Repository.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/untitled/Shop.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/Shop.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/Shop.java"
afterDir=
"false"
/>
</list>
<ignored
path=
"$PROJECT_DIR$/out/"
/>
...
...
@@ -19,10 +28,18 @@
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/src/Shop.java"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
322
"
>
<caret
line=
"3
37"
column=
"20"
selection-start-line=
"337"
selection-start-column=
"20"
selection-end-line=
"337"
selection-end-column=
"20
"
/>
<state
relative-caret-position=
"
653
"
>
<caret
line=
"3
88"
column=
"5"
lean-forward=
"true"
selection-start-line=
"388"
selection-start-column=
"5"
selection-end-line=
"388"
selection-end-column=
"5
"
/>
<folding>
<element
signature=
"imports"
expanded=
"true"
/>
<element
signature=
"e#163#173#0"
expanded=
"true"
/>
<element
signature=
"e#319#325#0"
expanded=
"true"
/>
<element
signature=
"e#380#387#0"
expanded=
"true"
/>
<element
signature=
"method#increamentGood#0;class#Shop#0"
/>
<element
signature=
"e#3278#3279#0"
expanded=
"true"
/>
<element
signature=
"e#3360#3361#0"
expanded=
"true"
/>
<element
signature=
"class#Customer#0;class#Repository#0;class#Shop#0"
/>
<element
signature=
"class#Order#0;class#Repository#0;class#Shop#0"
/>
</folding>
</state>
</provider>
...
...
@@ -59,12 +76,13 @@
</navigator>
<panes>
<pane
id=
"Scope"
/>
<pane
id=
"PackagesPane"
/>
<pane
id=
"ProjectPane"
/>
<pane
id=
"PackagesPane"
/>
</panes>
</component>
<component
name=
"PropertiesComponent"
>
<property
name=
"SHARE_PROJECT_CONFIGURATION_FILES"
value=
"true"
/>
<property
name=
"com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp"
value=
"1555002746370"
/>
<property
name=
"project.structure.last.edited"
value=
"Modules"
/>
<property
name=
"project.structure.proportion"
value=
"0.0"
/>
<property
name=
"project.structure.side.proportion"
value=
"0.0"
/>
...
...
@@ -82,8 +100,8 @@
</option>
</component>
<component
name=
"RunManager"
>
<configuration
name=
"
Shop
"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"
Shop
"
/>
<configuration
name=
"
Main
"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"
sun.rmi.rmic.Main
"
/>
<module
name=
"untitled"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
...
...
@@ -91,7 +109,7 @@
</configuration>
<recent_temporary>
<list>
<item
itemvalue=
"Application.
Shop
"
/>
<item
itemvalue=
"Application.
Main
"
/>
</list>
</recent_temporary>
</component>
...
...
@@ -108,8 +126,17 @@
</task>
<servers
/>
</component>
<component
name=
"TodoView"
>
<todo-panel
id=
"selected-file"
>
<is-autoscroll-to-source
value=
"true"
/>
</todo-panel>
<todo-panel
id=
"all"
>
<are-packages-shown
value=
"true"
/>
<is-autoscroll-to-source
value=
"true"
/>
</todo-panel>
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"
-7"
y=
"-7"
width=
"1550"
height=
"838
"
extended-state=
"6"
/>
<frame
x=
"
0"
y=
"25"
width=
"1920"
height=
"984
"
extended-state=
"6"
/>
<editor
active=
"true"
/>
<layout>
<window_info
id=
"Image Layers"
order=
"0"
/>
...
...
@@ -118,18 +145,18 @@
<window_info
id=
"Capture Tool"
order=
"3"
/>
<window_info
id=
"Favorites"
order=
"4"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"5"
side_tool=
"true"
weight=
"0.25"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"6"
visible=
"true"
weight=
"0.023489933
"
/>
<window_info
active=
"true"
content_ui=
"combo"
id=
"Project"
order=
"6"
visible=
"true"
weight=
"0.02347919
"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Find"
order=
"1"
weight=
"0.3286119"
/>
<window_info
anchor=
"bottom"
id=
"Run"
order=
"2"
weight=
"0.28045326"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Cvs"
order=
"4"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"TODO"
order=
"6"
/>
<window_info
anchor=
"bottom"
id=
"TODO"
order=
"6"
weight=
"0.32905483"
/>
<window_info
anchor=
"bottom"
id=
"Terminal"
order=
"7"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"10"
/>
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"10"
weight=
"0.32982457"
/>
<window_info
anchor=
"right"
id=
"Commander"
internal_type=
"SLIDING"
order=
"0"
type=
"SLIDING"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"right"
content_ui=
"combo"
id=
"Hierarchy"
order=
"2"
weight=
"0.25"
/>
...
...
@@ -143,10 +170,18 @@
<component
name=
"editorHistoryManager"
>
<entry
file=
"file://$PROJECT_DIR$/src/Shop.java"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
322
"
>
<caret
line=
"3
37"
column=
"20"
selection-start-line=
"337"
selection-start-column=
"20"
selection-end-line=
"337"
selection-end-column=
"20
"
/>
<state
relative-caret-position=
"
653
"
>
<caret
line=
"3
88"
column=
"5"
lean-forward=
"true"
selection-start-line=
"388"
selection-start-column=
"5"
selection-end-line=
"388"
selection-end-column=
"5
"
/>
<folding>
<element
signature=
"imports"
expanded=
"true"
/>
<element
signature=
"e#163#173#0"
expanded=
"true"
/>
<element
signature=
"e#319#325#0"
expanded=
"true"
/>
<element
signature=
"e#380#387#0"
expanded=
"true"
/>
<element
signature=
"method#increamentGood#0;class#Shop#0"
/>
<element
signature=
"e#3278#3279#0"
expanded=
"true"
/>
<element
signature=
"e#3360#3361#0"
expanded=
"true"
/>
<element
signature=
"class#Customer#0;class#Repository#0;class#Shop#0"
/>
<element
signature=
"class#Order#0;class#Repository#0;class#Shop#0"
/>
</folding>
</state>
</provider>
...
...
out/production/untitled/Shop$1.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop$Customer.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop$Discount.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop$Good.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop$Order.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop$Repository.class
deleted
100644 → 0
View file @
a086d581
File deleted
out/production/untitled/Shop.class
deleted
100644 → 0
View file @
a086d581
File deleted
src/Shop.java
View file @
e4b85bb3
import
com.sun.org.apache.xpath.internal.operations.Or
;
import
java.awt.*
;
import
java.util.Iterator
;
import
java.util.Scanner
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
javax.print.DocFlavor
;
import
java.util.*
;
public
class
Shop
{
...
...
@@ -28,8 +25,35 @@ public class Shop {
public
void
addGood
(
Good
g
){
Goods
.
add
(
g
);}
public
void
increamentGood
(
Good
good
,
int
amount
)
{
// todo increament ro adan benevisam
int
d
=
Repositorys
.
size
();
Goods
.
add
(
good
);
Repository
arr
[
]
=
new
Repository
[
d
];
for
(
int
i
=
0
;
i
<
d
;
i
++)
{
arr
[
i
]
=
Repositorys
.
get
(
i
);
}
Arrays
.
sort
(
arr
,
new
SortbyFreeCapacity
());
for
(
Repository
repository:
arr
)
{
if
(
repository
.
getFreeCapacity
()>
amount
)
{
repository
.
addGood
(
good
,
amount
);
break
;
}
}
}
static
class
SortbyFreeCapacity
implements
Comparator
<
Repository
>
{
// Used for sorting in ascending order of
// roll number
public
int
compare
(
Repository
a
,
Repository
b
)
{
return
a
.
getFreeCapacity
()-
b
.
getFreeCapacity
();
}
}
// public void addDiscount(Discount d, Customer c){}
...
...
@@ -48,20 +72,37 @@ static class Repository{
{
this
.
id
=
id
;
this
.
capacity
=
capacity
;
this
.
filledCapacity
=
0
;
}
public
HashMap
<
Good
,
Integer
>
getListOfGoodsinRepository
()
{
return
listOfGoodsinRepository
;
}
public
void
removeGood
(
Good
g
,
int
amount
)
public
void
removeGood
(
Good
g
ood
,
int
amount
)
{
int
remain
;
remain
=
listOfGoodsinRepository
.
get
(
g
);
remain
-=
amount
;
if
(
remain
<=
0
)
{
listOfGoodsinRepository
.
remove
(
g
);
}
remain
=
listOfGoodsinRepository
.
get
(
good
);
if
(
(
remain
-
amount
)
>
0
)
{
listOfGoodsinRepository
.
replace
(
good
,
remain
,
remain
-
amount
);
filledCapacity
=
filledCapacity
-
amount
;
}
}
public
void
addGood
(
Good
good
,
int
amount
)
{
listOfGoodsinRepository
.
put
(
good
,
amount
);
}
{
if
(
listOfGoodsinRepository
.
containsKey
(
good
)
)
{
listOfGoodsinRepository
.
replace
(
good
,
listOfGoodsinRepository
.
get
(
good
),
listOfGoodsinRepository
.
get
(
good
)+
amount
);
filledCapacity
+=
amount
;
}
else
{
listOfGoodsinRepository
.
put
(
good
,
amount
);
filledCapacity
+=
amount
;
}
}
public
int
getId
()
{
return
id
;
...
...
@@ -205,118 +246,119 @@ static class Repository{
String
entering
;
Shop
MyShop
=
new
Shop
();
Scanner
scan
=
new
Scanner
(
System
.
in
)
;
while
(
true
){
entering
=
scan
.
nextLine
();
if
(
entering
.
equals
(
"terminate"
))
return
;
if
(
entering
.
equals
(
"add"
))
{
String
add
=
scan
.
nextLine
();
if
(
add
.
equals
(
"customer"
))
{
int
id
=
scan
.
nextInt
();
String
name
=
scan
.
nextLine
();
Customer
c
=
new
Customer
(
name
,
id
);
MyShop
.
addCustomer
(
c
);
}
if
(
add
.
equals
(
"good"
))
{
if
(
add
.
equals
(
"customer"
))
{
int
id
=
scan
.
nextInt
();
String
name
=
scan
.
nextLine
();
Customer
c
=
new
Customer
(
name
,
id
);
MyShop
.
addCustomer
(
c
);
}
if
(
add
.
equals
(
"good"
))
{
int
id
=
scan
.
nextInt
();
int
id
=
scan
.
nextInt
();
scan
.
nextLine
();
String
name
=
scan
.
nextLine
();
scan
.
nextLine
();
String
name
=
scan
.
nextLine
();
int
price
=
scan
.
nextInt
();
int
price
=
scan
.
nextInt
();
int
amount
=
scan
.
nextInt
();
int
amount
=
scan
.
nextInt
();
Good
good
=
new
Good
(
id
,
name
,
price
);
MyShop
.
addGood
(
good
);
MyShop
.
increamentGood
(
good
,
amount
);
Good
good
=
new
Good
(
id
,
name
,
price
);
MyShop
.
addGood
(
good
);
MyShop
.
increamentGood
(
good
,
amount
);
}
if
(
add
.
equals
(
"repository"
))
{
int
id
=
scan
.
nextInt
();
int
capacity
=
scan
.
nextInt
();
Repository
store
=
new
Repository
(
id
,
capacity
);
MyShop
.
addRepository
(
store
);
}
if
(
add
.
equals
(
"order"
))
{
int
idOfOrder
=
scan
.
nextInt
();
int
idOfCustomer
=
scan
.
nextInt
();
// Order order = new Order(idOfOrder);
}
if
(
add
.
equals
(
"repository"
))
{
int
id
=
scan
.
nextInt
();
int
capacity
=
scan
.
nextInt
();
Repository
store
=
new
Repository
(
id
,
capacity
);
MyShop
.
addRepository
(
store
);
}
if
(
add
.
equals
(
"order"
))
{
int
idOfOrder
=
scan
.
nextInt
();
int
idOfCustomer
=
scan
.
nextInt
();
// Order order = new Order(idOfOrder);
Customer
c
=
null
;
for
(
Customer
customer
:
MyShop
.
Customers
)
if
(
customer
.
getID
()==
idOfCustomer
)
c
=
customer
;
Order
order
=
new
Order
(
idOfOrder
,
c
);
MyShop
.
orders
.
add
(
order
);
Customer
c
=
null
;
for
(
Customer
customer
:
MyShop
.
Customers
)
if
(
customer
.
getID
()==
idOfCustomer
)
c
=
customer
;
Order
order
=
new
Order
(
idOfOrder
,
c
);
MyShop
.
orders
.
add
(
order
);
}
if
(
add
.
equals
(
"balance"
))
{
int
IdOfCustomer
=
scan
.
nextInt
();
int
balance
=
scan
.
nextInt
();
Customer
c
=
null
;
for
(
Customer
customer
:
MyShop
.
Customers
)
}
if
(
add
.
equals
(
"balance"
))
{
if
(
customer
.
getID
()
==
IdOfCustomer
)
c
=
customer
;
int
IdOfCustomer
=
scan
.
nextInt
();
int
balance
=
scan
.
nextInt
();
Customer
c
=
null
;
for
(
Customer
customer
:
MyShop
.
Customers
)
{
if
(
customer
.
getID
()
==
IdOfCustomer
)
c
=
customer
;
}
int
OldBalance
=
c
.
getBalance
();
int
NewBalance
=
OldBalance
+
balance
;
c
.
setBalance
(
NewBalance
);
}
int
OldBalance
=
c
.
getBalance
();
int
NewBalance
=
OldBalance
+
balance
;
c
.
setBalance
(
NewBalance
);
}
if
(
add
.
equals
(
"item"
))
{
int
idOfOrder
=
scan
.
nextInt
();
int
IdOfGood
=
scan
.
nextInt
();
int
NumberOfGood
=
scan
.
nextInt
();
if
(
add
.
equals
(
"item"
))
{
int
idOfOrder
=
scan
.
nextInt
();
int
IdOfGood
=
scan
.
nextInt
();
int
NumberOfGood
=
scan
.
nextInt
();
for
(
Order
order
:
MyShop
.
orders
){
for
(
Order
order
:
MyShop
.
orders
){
if
(
order
.
getID
()
==
idOfOrder
)
{
for
(
Good
good
:
order
.
getItems
().
keySet
())
{
if
(
good
.
getId
()
==
IdOfGood
)
{
int
oldNuberOfGood
=
order
.
getItems
().
get
(
good
);
order
.
getItems
().
replace
(
good
,
oldNuberOfGood
,
oldNuberOfGood
+
NumberOfGood
);
if
(
order
.
getID
()
==
idOfOrder
)
{
for
(
Good
good
:
order
.
getItems
().
keySet
())
{
if
(
good
.
getId
()
==
IdOfGood
)
{
int
oldNuberOfGood
=
order
.
getItems
().
get
(
good
);
order
.
getItems
().
replace
(
good
,
oldNuberOfGood
,
oldNuberOfGood
+
NumberOfGood
);
}
else
{
order
.
Items
.
put
(
good
,
NumberOfGood
);
}
}
}
}
else
{
order
.
Items
.
put
(
good
,
NumberOfGood
);
}
}
}
}
}}
}
}}
if
(
entering
.
equals
(
"report"
))
{
// except customers others are complete;
String
report
=
scan
.
nextLine
();
if
(
report
.
equals
(
"repositories"
))
{
for
(
Repository
repo
:
MyShop
.
Repositorys
)
{
System
.
out
.
println
(
repo
.
id
+
","
+
repo
.
capacity
+
","
+
repo
.
getFreeCapacity
());
}
}
if
(
report
.
equals
(
"income"
)){
System
.
out
.
println
(
MyShop
.
getIncome
());
}
if
(
report
.
equals
(
"customers"
));
/*
if
(
report
.
equals
(
"repositories"
))
{
for
(
Repository
repo
:
MyShop
.
Repositorys
)
{
System
.
out
.
println
(
repo
.
id
+
","
+
repo
.
capacity
+
","
+
repo
.
getFreeCapacity
());
}
}
if
(
report
.
equals
(
"income"
)){
System
.
out
.
println
(
MyShop
.
getIncome
());
}
if
(
report
.
equals
(
"customers"
));
/*
//todo about custromers
{
for (Customer customer : MyShop.Customers){
System.out.println(customer.getID()+","+customer.getName()+","+customer.getBalance()+",");
}}*/
}
}
if
(
entering
.
equals
(
"submit"
))
{
String
submit
=
scan
.
nextLine
();
...
...
@@ -335,12 +377,14 @@ static class Repository{
{
int
IdOfOrder
=
scan
.
nextInt
();
int
IdOfPercet
=
scan
.
nextInt
();
}
}
}}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment