Advertisement
cd62131

SatouMizuMaze

May 24th, 2019
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.62 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. public class SatouMizuMaze {
  5.   public static void main(String[] args) {
  6.     List<SatouMizu> a = new ArrayList<>();
  7.     for (int i = 10; i < 51; ++i) {
  8.       a.add(new SatouMizu(110 - i, 20, i));
  9.     }
  10.     System.out.println(a.stream().reduce((x, y) -> x.mazeru(y)).get());
  11.   }
  12. }
  13.  
  14. class Mizu {
  15.   protected double mizu_shitsuryou, ondo;
  16.  
  17.   public Mizu(double s, double o) {
  18.     mizu_shitsuryou = s;
  19.     ondo = o;
  20.   }
  21.  
  22.   public Mizu mazeru(Mizu aite) {
  23.     return new Mizu(
  24.         mizu_shitsuryou + aite.mizu_shitsuryou,
  25.         (ondo * mizu_shitsuryou + aite.ondo * aite.mizu_shitsuryou)
  26.             / (mizu_shitsuryou + aite.mizu_shitsuryou));
  27.   }
  28.  
  29.   public String toString() {
  30.     return String.format("mizu: mizu_shitsuryou = %.1f, ondo = %.1f", mizu_shitsuryou, ondo);
  31.   }
  32. }
  33.  
  34. class SatouMizu extends Mizu {
  35.   protected double satou_shitsuryou;
  36.  
  37.   public SatouMizu(double s, double o, double st) {
  38.     super(s, o);
  39.     satou_shitsuryou = st;
  40.   }
  41.  
  42.   public SatouMizu mazeru(SatouMizu aite) {
  43.     return new SatouMizu(
  44.         mizu_shitsuryou + aite.mizu_shitsuryou,
  45.         (ondo * mizu_shitsuryou + aite.ondo * aite.mizu_shitsuryou)
  46.             / (mizu_shitsuryou + aite.mizu_shitsuryou),
  47.         satou_shitsuryou + aite.satou_shitsuryou);
  48.   }
  49.  
  50.   public String toString() {
  51.     return String.format(
  52.         "satoumizu: mizu_shitsuryou = %.1f, ondo = %.1f, satou_shitsuryou = %.1f, noudo = %.1f%%",
  53.         mizu_shitsuryou,
  54.         ondo,
  55.         satou_shitsuryou,
  56.         100.0 * satou_shitsuryou / (satou_shitsuryou + mizu_shitsuryou));
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement