我目前正在制作一个游戏,发生在大四的10多天。我为这款游戏创建了一个介绍,但我不确定如何把它放在一起。我应该将介绍作为父类,并且每天都有不同的子类?这是我的代码到目前为止。基于文本的游戏与选择,发生在多天
package SeniorGame;
import java.util.Scanner;
public class Intro{
public static void main (String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("Before the game begins I need to know a few things about yourself.");
System.out.println();
String name;
System.out.println("What is your name? ");
name=sc.next();
String crush;
System.out.println("Who was your High School crush? ");
crush=sc.next();
String bfriend;
System.out.println("Who was your best friend in High School? ");
bfriend=sc.next();
System.out.println();
System.out.println();
System.out.println("This is a story that consits of 12 days in your senior year of High School.\n"
+ "The days are spread out from the beginning to the end of the year.\nThe choices you make"
+ " will impact the way your story plays out.");
}
}
'extends'提炼行为并用于“is-a”关系(香蕉是一种水果)。与你的介绍有关系吗? – zapl
从技术上讲,介绍不是一个独立的东西。如果这是有道理的。从介绍开始,你将被提升为游戏菜单,以播放或退出。如果你退出system.quit(1)行触发器,但如果不行,你显然会玩游戏。我的问题是如何从这里开始第一天。我是否以单独的课程或单独的方法进行第一天课程? –
我会让每一天继承Day类。让外部的课程处理日常移动的逻辑,记录日期可能会分享的变量等。 –