Bar.java 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.example.data_structure.vo;
  2. import org.springframework.stereotype.Component;
  3. @Component
  4. public class Bar {
  5. private int value;
  6. private String color;
  7. public Bar(int value, String color) {
  8. this.value = value;
  9. this.color = color;
  10. }
  11. public Bar() {
  12. }
  13. //getter
  14. public int getValue() {
  15. return value;
  16. }
  17. public String getColor() {
  18. return color;
  19. }
  20. //setter
  21. public void setValue(int value) {
  22. this.value = value;
  23. }
  24. public void setColor(String color) {
  25. this.color = color;
  26. }
  27. //toString
  28. @Override
  29. public String toString() {
  30. return "Bar{" +
  31. "value=" + value +
  32. ", color='" + color + '\'' +
  33. '}';
  34. }
  35. //copy
  36. public static Bar copyBar(Bar bar){
  37. Bar copyBar=new Bar(bar.getValue(),bar.getColor());
  38. return copyBar;
  39. }
  40. }