Commit c42eb2dc authored by 9731029's avatar 9731029

the first commit

parents
Pipeline #432 canceled with stages
<?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">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/untitled.iml" filepath="$PROJECT_DIR$/untitled.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="67bfc981-7b10-4bf4-963c-b8f3544bb91a" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DefaultGradleProjectSettings">
<option name="testRunner" value="GRADLE" />
<option name="delegatedBuild" value="true" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<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="153">
<caret line="76" column="23" lean-forward="true" selection-start-line="76" selection-start-column="23" selection-end-line="76" selection-end-column="23" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3870#3871#0" expanded="true" />
<element signature="e#3906#3907#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/Shop.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-10" />
<option name="y" value="-10" />
<option name="width" value="1065" />
<option name="height" value="980" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="untitled" type="b2602c69:ProjectViewProjectNode" />
<item name="untitled" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<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" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Shop" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Shop" />
<module name="untitled" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Shop" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="67bfc981-7b10-4bf4-963c-b8f3544bb91a" name="Default Changelist" comment="" />
<created>1554718564879</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1554718564879</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
<layout>
<window_info id="Image Layers" order="0" />
<window_info id="Designer" order="1" />
<window_info id="UI Designer" order="2" />
<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 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="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="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" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Maven" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Capture Analysis" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/Shop.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="76" column="23" lean-forward="true" selection-start-line="76" selection-start-column="23" selection-end-line="76" selection-end-column="23" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3870#3871#0" expanded="true" />
<element signature="e#3906#3907#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>untitled</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
in the add of item what is ("شناسه خرید ");
does it mean the id of order:::??
\ No newline at end of file
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;
public class Shop {
private String nameOfShop;
private ArrayList <Customer> Customers = new ArrayList<Customer> ( );
private ArrayList <Repository> Repositorys = new ArrayList<Repository>();
private ArrayList <Good> Goods = new ArrayList<Good>();
private ArrayList<Order > orders = new ArrayList<Order>();
private static int income =0;
public void addCustomer(Customer C)
{ Customers.add(C); }
public ArrayList<Customer> getCustomers()
{ return Customers; }
public void addRepository(Repository R)
{ Repositorys.add(R);}
public ArrayList<Repository> getRepository()
{ return Repositorys;}
public int getIncome(){return income;}
public void setIncome(int income){this.income = income;}
public void addGood(Good g){ Goods.add(g);}
public void increamentGood(Good good, int amount)
{
// todo increament ro adan benevisam
}
// public void addDiscount(Discount d, Customer c){}
// public HashMap<Good, Integer> getItemsSold(){};
static class Repository{
private int id;
private int capacity;
private int filledCapacity;
private HashMap < Good , Integer> listOfGoodsinRepository = new HashMap<Good,Integer>();
private Repository(int id ,int capacity)
{
this.id = id;
this.capacity = capacity;
}
public HashMap <Good,Integer> getListOfGoodsinRepository()
{ return listOfGoodsinRepository; }
public void removeGood(Good g, int amount)
{
int remain ;
remain = listOfGoodsinRepository.get(g);
remain -= amount;
if( remain <= 0 )
{ listOfGoodsinRepository.remove(g); }
}
public void addGood( Good good , int amount)
{ listOfGoodsinRepository.put(good,amount); }
public int getId() {
return id;
}
public int getCapacity()
{
return capacity;
}
public int getFreeCapacity()
{ return (capacity -filledCapacity);}
}
static class Good{
private int id;
private int price ;
private String name;
public Good(int id ,String name, int price)
{
this.id= id;
this.name= name;
this.price =price;
}
public int getId()
{ return id; }
public int getPrice()
{return price;}
public String getName()
{ return name;}
}
static class Customer{
private String name;
private int ID;
private int balance;
ArrayList <Order> orders = new ArrayList<Order>();
ArrayList <Order> pendingOrders = new ArrayList<Order>();
public Customer (String name ,int id)
{ this.name = name;
ID = id;
}
public int getID(){return ID;}
public String getName () {return name;}
public int getBalance(){return balance;}
public void setBalance(int amount)
{
balance = amount;
}
public void addorder(Order o)
{
orders.add(o);
}
public ArrayList<Order> getTOtalOrder()
{ return orders; }
public ArrayList<Order> getPendingOrders()
{
return pendingOrders;
}
}
static class Order{
private int ID;
private String status;
private Customer c;
HashMap <Good,Integer> Items = new HashMap<Good,Integer>();
public Order(int id , Customer c)
{
ID = id;
this.c = c;
}
public Order (int id){
this.ID = id;
}
public int getID()
{
return ID;
}
public String getStatus()
{
return status;
}
public HashMap<Good,Integer> getItems()
{
return Items;
}
public void setStatus(String status)
{
this.status = status;}
public void addItem(Good good, int amount)
{
if( Items.containsKey(good)){
int Oldamount = Items.get(good);
int Newamount = Oldamount + amount;
Items.replace(good, Oldamount, Newamount);
}
else {
Items.put(good , amount);
}
}
public void removeItem(Good good)
{
Iterator<Good> it = Items.keySet().iterator();
while(it.hasNext())
{
Good sample = it.next();
if ( sample.getId() == good.getId() ) it.remove();
}
}
}
public class Discount{}
public static void main(String[] args)
{
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"))
{
int id = scan.nextInt();
scan.nextLine();
String name =scan.nextLine();
int price = scan.nextInt();
int amount = scan.nextInt();
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);
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(customer.getID() == IdOfCustomer)
c = customer;
}
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();
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);
}
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"));/*
//todo about custromers
{
for (Customer customer : MyShop.Customers){
System.out.println(customer.getID()+","+customer.getName()+","+customer.getBalance()+",");
}}*/
}
}}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment