質問編集履歴
2
質問内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -658,7 +658,7 @@
|
|
658
658
|
|
659
659
|
|
660
660
|
|
661
|
-
public Item(String id, String name, int price, int quantity, int subtotal) {
|
661
|
+
public Item(String id, String name, int price, int quantity, int subtotal, int pos) {
|
662
662
|
|
663
663
|
this.id = id;
|
664
664
|
|
@@ -670,6 +670,8 @@
|
|
670
670
|
|
671
671
|
this.subtotal = subtotal;
|
672
672
|
|
673
|
+
this.pos = pos;
|
674
|
+
|
673
675
|
}
|
674
676
|
|
675
677
|
}
|
1
質問内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -575,3 +575,103 @@
|
|
575
575
|
|
576
576
|
|
577
577
|
```
|
578
|
+
|
579
|
+
Item.java
|
580
|
+
|
581
|
+
```java
|
582
|
+
|
583
|
+
public class Item {
|
584
|
+
|
585
|
+
private String id;
|
586
|
+
|
587
|
+
private String name;
|
588
|
+
|
589
|
+
private int price;
|
590
|
+
|
591
|
+
private int quantity;
|
592
|
+
|
593
|
+
private int subtotal;
|
594
|
+
|
595
|
+
private int pos;
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
@Override
|
600
|
+
|
601
|
+
public int hashCode() {
|
602
|
+
|
603
|
+
final int prime = 31;
|
604
|
+
|
605
|
+
int result = 1;
|
606
|
+
|
607
|
+
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
608
|
+
|
609
|
+
return result;
|
610
|
+
|
611
|
+
}
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
@Override
|
616
|
+
|
617
|
+
public boolean equals(Object obj) {
|
618
|
+
|
619
|
+
if (this == obj) {
|
620
|
+
|
621
|
+
return true;
|
622
|
+
|
623
|
+
}
|
624
|
+
|
625
|
+
if (obj == null) {
|
626
|
+
|
627
|
+
return false;
|
628
|
+
|
629
|
+
}
|
630
|
+
|
631
|
+
if (!(obj instanceof Item)) {
|
632
|
+
|
633
|
+
return false;
|
634
|
+
|
635
|
+
}
|
636
|
+
|
637
|
+
Item other = (Item) obj;
|
638
|
+
|
639
|
+
if (id == null) {
|
640
|
+
|
641
|
+
if (other.id != null) {
|
642
|
+
|
643
|
+
return false;
|
644
|
+
|
645
|
+
}
|
646
|
+
|
647
|
+
} else if (!id.equals(other.id)) {
|
648
|
+
|
649
|
+
return false;
|
650
|
+
|
651
|
+
}
|
652
|
+
|
653
|
+
return true;
|
654
|
+
|
655
|
+
}
|
656
|
+
|
657
|
+
/*それぞれのgetterとsetterを生成してあります。*/
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
public Item(String id, String name, int price, int quantity, int subtotal) {
|
662
|
+
|
663
|
+
this.id = id;
|
664
|
+
|
665
|
+
this.name = name;
|
666
|
+
|
667
|
+
this.price = price;
|
668
|
+
|
669
|
+
this.quantity = quantity;
|
670
|
+
|
671
|
+
this.subtotal = subtotal;
|
672
|
+
|
673
|
+
}
|
674
|
+
|
675
|
+
}
|
676
|
+
|
677
|
+
```
|