| 12345678910111213141516171819202122232425262728 |
- package main.java.com.sf.part05.oop_02;
- public class Car {
- double weight;
- int horsepower;
- public double proportion(){
- return horsepower * 10 / weight;
- }
- public String getInfo(){
- return "Car{" +
- "weight=" + weight +
- ", horsepower=" + horsepower +
- ", proportion=" + proportion() +
- '}';
- }
- @Override
- public String toString() {
- return "Car{" +
- "weight=" + weight +
- ", horsepower=" + horsepower +
- ", proportion=" + proportion() +
- '}';
- }
- }
|