드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
게시물ID : computer_21495짧은주소 복사하기
작성자 : 눈팅눈팅★
추천 : 0
조회수 : 420회
댓글수 : 4개
등록시간 : 2011/10/24 14:13:31
import java.io.*;
class Distance {
static float distance = 0;
}
class Station {
int num;
String name;
Way[] way = new Way[2];
Station(int num, String name) {
this.num = num;
this.name = name;
}
void goDist(int num) {
System.out.print(name);
if(this.num<num) {
goNext(num);
}
else if(this.num>num) {
goPrev(num);
}
else System.out.println();
}
void goNext(int num) {
if(way[1]!=null) {
way[1].goNext(num);
}
else System.out.println("-|여기가 끝이여");
}
void goPrev(int num) {
if(way[0]!=null) {
way[0].goPrev(num);
}
else System.out.println("-|여기가 끝이여");
}
}
class Way {
float distance;
Station[] station = new Station[2];
Way(Station one, float distance, Station other) {
this.distance = distance;
station[0] = one;
station[1] = other;
one.way[1] = this;
other.way[0] = this;
}
void goNext(int num) {
System.out.print("->");
Distance.distance += this.distance;
station[1].goDist(num);
}
void goPrev(int num) {
System.out.print("->");
Distance.distance += this.distance;
station[0].goDist(num);
}
}
class Subway2 {
String start;
String end;
public void setstart(String start) {
this.start=start;
}
public void setend(String end) {
this.end=end;
}
public String getstart() {
return start;
}
public String getend() {
return end;
}
}
public class Subway extends Subway2 {
public static void main(String args[]) {
String[] names = new String[23];
Station[] stations = new Station[23];
float[] dists = new float[]{1,1.5f,1.1f,1.1f,0.9f,0.9f,1.5f,0.9f,1.2f,0.9f,0.8f,1.1f,1.3f,1.3f,0.9f,0.8f,0.8f,0.6f,1.4f,0.8f,1.1f,1};
Way[] ways = new Way[22];
names[0] = "계양";
names[1] = "귤현";
names[2] = "박촌";
names[3] = "임학";
names[4] = "계산";
names[5] = "경인교대입구";
names[6] = "작전";
names[7] = "갈산";
names[8] = "부평구청";
names[9] = "부평시장";
names[10] = "부평";
names[11] = "동수";
names[12] = "부평삼거리";
names[13] = "간석오거리";
names[14] = "인천시청";
names[15] = "예술회관";
names[16] = "인천터미널";
names[17] = "문학경기장";
names[18] = "선학";
names[19] = "신연수";
names[20] = "원인재";
names[21] = "동춘";
names[22] = "동막";
for(int i=0;i<names.length;i++) {
stations[i] = new Station(i, names[i]);
if(i>0 && i<names.length) ways[i-1] = new Way(stations[i-1],dists[i-1],stations[i]);
if(i%4==0) System.out.println();
System.out.printf("[%02d]%s \t",i,names[i]);
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String start = "", end = "";
try{
System.out.println("출발역을 선택하세요.");
System.out.print("출발역: ");
start = br.readLine();
System.out.println("도착역을 선택하세요.");
System.out.print("도착역: ");
end = br.readLine();
}catch(IOException e){
e.printStackTrace();
}
Station startStation = null;
for(int i=0;i<stations.length;i++) {
if(stations[i].num==Integer.parseInt(start)) startStation = stations[i];
}
startStation.goDist(Integer.parseInt(end));
int fee = 0;
int addfee = 0;
if(Distance.distance<10) fee = 900;
else if(Distance.distance>=10) {
fee = 1000;
addfee = (int)((Distance.distance - 10)/ 5)*100;
}
System.out.printf("이동거리 : %.1f km\n", Distance.distance);
System.out.println("요금은 : "+(fee+addfee)+"원");
}
}
이거돌리면
Static Error: This class does not have a static void main method accepting String[].
라고 하는데 ㅜㅜㅜ
왜 메인메소드잇는데 왜이래용 ㅜㅜㅜㅜㅜㅜ
댓글 분란 또는 분쟁 때문에
전체 댓글이 블라인드 처리되었습니다.
새로운 댓글이 없습니다.