복습: 소포 송장
Coddy의 Python 개발자를 위한 Dart 코스 레슨. 48개 중 6번째.
챌린지
쉬움invoice(int count, int price, int fee)를 구현하세요. count와 price를 곱한 값에 fee를 더해 반환하세요. 입력은 0 이상 1000 이하의 정수 세 개입니다. count가 0이어도 fee는 부과됩니다.
편집 가능한 파일에서 출력하지 마세요. 제공된 exercise.dart는 입력을 파싱하고 출력을 반환하며, 잠긴 드라이버는 공개 API를 별도로 테스트하고 결과를 줄바꿈 문자 하나와 함께 출력합니다.
코드는 functions.dart, exercise.dart에 작성하세요. main.dart에는 제공된 입력/출력 코드가 있으며 수정할 수 없습니다.
직접 해보기
import 'dart:io';
import 'dart:convert';
import 'exercise.dart';
import 'functions.dart';
void check(bool condition){if(!condition)throw StateError('Public API contract failed');}
Future<void> main() async {
final raw=await stdin.transform(utf8.decoder).join();
final input=raw.replaceFirst(RegExp(r'\r?\n$'),'');
check(invoice(3,4,2)==14);
stdout.writeln(solve(input));
}
Python 개발자를 위한 Dart의 모든 레슨
직접 연습해 보세요: 온라인 Dart 컴파일러