Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class SatouMizuMaze {
- public static void main(String[] args) {
- List<SatouMizu> a = new ArrayList<>();
- for (int i = 10; i < 51; ++i) {
- a.add(new SatouMizu(110 - i, 20, i));
- }
- System.out.println(a.stream().reduce((x, y) -> x.mazeru(y)).get());
- }
- }
- class Mizu {
- protected double mizu_shitsuryou, ondo;
- public Mizu(double s, double o) {
- mizu_shitsuryou = s;
- ondo = o;
- }
- public Mizu mazeru(Mizu aite) {
- return new Mizu(
- mizu_shitsuryou + aite.mizu_shitsuryou,
- (ondo * mizu_shitsuryou + aite.ondo * aite.mizu_shitsuryou)
- / (mizu_shitsuryou + aite.mizu_shitsuryou));
- }
- public String toString() {
- return String.format("mizu: mizu_shitsuryou = %.1f, ondo = %.1f", mizu_shitsuryou, ondo);
- }
- }
- class SatouMizu extends Mizu {
- protected double satou_shitsuryou;
- public SatouMizu(double s, double o, double st) {
- super(s, o);
- satou_shitsuryou = st;
- }
- public SatouMizu mazeru(SatouMizu aite) {
- return new SatouMizu(
- mizu_shitsuryou + aite.mizu_shitsuryou,
- (ondo * mizu_shitsuryou + aite.ondo * aite.mizu_shitsuryou)
- / (mizu_shitsuryou + aite.mizu_shitsuryou),
- satou_shitsuryou + aite.satou_shitsuryou);
- }
- public String toString() {
- return String.format(
- "satoumizu: mizu_shitsuryou = %.1f, ondo = %.1f, satou_shitsuryou = %.1f, noudo = %.1f%%",
- mizu_shitsuryou,
- ondo,
- satou_shitsuryou,
- 100.0 * satou_shitsuryou / (satou_shitsuryou + mizu_shitsuryou));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement