teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

質問内容の修正

2019/09/27 00:13

投稿

naotaro0704
naotaro0704

スコア19

title CHANGED
File without changes
body CHANGED
@@ -328,12 +328,13 @@
328
328
  }
329
329
  /*それぞれのgetterとsetterを生成してあります。*/
330
330
 
331
- public Item(String id, String name, int price, int quantity, int subtotal) {
331
+ public Item(String id, String name, int price, int quantity, int subtotal, int pos) {
332
332
  this.id = id;
333
333
  this.name = name;
334
334
  this.price = price;
335
335
  this.quantity = quantity;
336
336
  this.subtotal = subtotal;
337
+ this.pos = pos;
337
338
  }
338
339
  }
339
340
  ```

1

質問内容の修正

2019/09/27 00:13

投稿

naotaro0704
naotaro0704

スコア19

title CHANGED
File without changes
body CHANGED
@@ -286,4 +286,54 @@
286
286
 
287
287
  </form:form>
288
288
 
289
+ ```
290
+ Item.java
291
+ ```java
292
+ public class Item {
293
+ private String id;
294
+ private String name;
295
+ private int price;
296
+ private int quantity;
297
+ private int subtotal;
298
+ private int pos;
299
+
300
+ @Override
301
+ public int hashCode() {
302
+ final int prime = 31;
303
+ int result = 1;
304
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
305
+ return result;
306
+ }
307
+
308
+ @Override
309
+ public boolean equals(Object obj) {
310
+ if (this == obj) {
311
+ return true;
312
+ }
313
+ if (obj == null) {
314
+ return false;
315
+ }
316
+ if (!(obj instanceof Item)) {
317
+ return false;
318
+ }
319
+ Item other = (Item) obj;
320
+ if (id == null) {
321
+ if (other.id != null) {
322
+ return false;
323
+ }
324
+ } else if (!id.equals(other.id)) {
325
+ return false;
326
+ }
327
+ return true;
328
+ }
329
+ /*それぞれのgetterとsetterを生成してあります。*/
330
+
331
+ public Item(String id, String name, int price, int quantity, int subtotal) {
332
+ this.id = id;
333
+ this.name = name;
334
+ this.price = price;
335
+ this.quantity = quantity;
336
+ this.subtotal = subtotal;
337
+ }
338
+ }
289
339
  ```