2021-03-15

represent different classes students must complete in order to graduate.

You will be implementing four classes: GameSettings, Level, Student , and PlayGame. The full game overview is below:

Overview

Students of CS is a game in which CS majors at any university must complete levels representing the courses taken in the major (such as CS 18000, CS 24000, and so on). Each of the courses are labeled numerically, beginning with 1 and ending with 12. Each level will be comprised of many obstacles that will need to be overcome. There will also be difficult topics that must be mastered before the student can progress to the next level. After completing each level, the student will be able to graduate!

Task:

This game has 12 levels. The student will face 4 difficult topics and 5 projects per level (either small or big projects). All three of these features (number of levels, hard topics per level, and projects per level) can be customized, but the default values will be 12, 4, and 5, respectively. The maximum number of hard topics and projects incomplete that the student can afford without having to retry the level (retake the course) is 2. Essentially, each incomplete project or topic not understood is a strike and if a student gets 3 strikes, they must retry the level. Additionally, some projects are capstone projects, which will result in an automatic retry if the student fails. Lastly, a student can “ace tests”, which adds one to the number of hard topics or incomplete projects they are allowed to have. Let’s go through an example:

With 1 aced test, 3 hard topics, and 0 projects (both standard and capstone), a student will pass the level. With the aced tests, the number of allowed incomplete topics and projects increases to 3.

For another example, with 2 aced tests, 1 hard topics, 1 incomplete projects, and 1 incomplete capstone project, the student would fail the level. An incomplete capstone is an automatic retake.

The program will follow the student’s college career and display information about their accomplishments. If the student graduates, information about the obstacles completed along the way will also be displayed. More information on the methods and classes is provided below.

Note: 5 points of your grade is based on Coding Style. You will need to update the Starter Code to follow the standards described here. Use the “Run” button to check your Coding Style without using a submission.

Instructions

Follow the instructions for each class.

GameSettings.java

This class represents the game settings for Students of CS or in other words, what obstacles the student must overcome

Fields

Field Name

Type

Access Modifier

Description

levels

int

private

Number of levels

hardTopicsPerLevel

int

private

Number of complicated topics per level

projectsPerLevel

int

private

Number of projects per level

Constructor

Access Modifier

Constructor Name

Input Parameters

Description

public

GameSettings

Construct a newly allocated GameSettings object and instantiate the fields to the following:

levels to 12.
hardTopicsPerLevel to 4.
projectsPerLevel to 5.
Methods

Method Name

Return Type

Access Modifier

Input Parameters

Description

toString

String

public

Return information about the game settings in the format provided in the next section.

getLevels

int

public

Returns the levels of this GameSettings.

getHardTopicsPerLevel

int

public

Returns the hardTopicsPerLevel of this GameSettings.

getProjectsPerLevel

int

public

Returns the projectsPerLevel of this GameSettings.

customize

void

public

int levelsChange, int topicsChange, int projectsChange

Customize the settings by changing the values of the instance variables based on the parameters given as input.

If the parameter is positive, the value of the corresponding field should increase and if the parameter is negative, the value should decrease.

Leave the instance variable as is if the corresponding parameter is 0.

toString format

Course Obstacles:

Levels:

Hard Topics Per Level:

Projects Per Level:

Student.java

This class represents the student character.

Fields

Field Name

Type

Access Modifier

Description

name

String

private

Name of student.

university

String

private

University student attends.

hardTopicsMastered

int

private

Indicates number of hard topics the student has mastered.

projectsCompleted

int

private

Indicates the number of projects the student has completed.

graduated

boolean

private

Indicates whether or not the student has graduated (true if all levels have been passed).

careerTime

double

private

Indicates total time college career has taken in years as a decimal.

The total time of all courses will be calculated by summing up the time taken in each of the levels (courses) and should be rounded to the nearest multiple of 0.5.

For example, a total time in all the levels of 3.2 should be rounded to 3.5 and 3.75 should be rounded to 4. The field is always rounded up, never down.

Constructors:

Access Modifier

Constructor Name

Input Parameters

Description

public

Student

String name,

String university,

int hardTopicsMastered,

int projectsCompleted,

boolean graduated,

double careerTime

Construct a newly allocated Student object and instantiate the fields to the specified parameters.

Methods:

Method Name

Return Type

Access Modifier

Input Parameters

Description

toString

String

public

Return information about the student in the format provided in the next section.

getName

String

public

Returns the name of this Student.

getUniversity

String

public

Returns the university of this Student.

getHardTopicsMastered

int

public

Returns the hardTopicsMastered of this Student.

getProjectsCompleted

int

public

Returns the projectsCompleted of this Student.

isGraduated

boolean

public

Returns the graduated status of this Student.

getCareerTime

double

public

Returns the careerTime of this Student.

setHardTopicsMastered

void

public

int hardTopicsMastered

Sets the hardTopicsMastered of this Student.

setProjectsCompleted

void

public

int projectsCompleted

Sets the projectsCompleted of this Student.

setGraduated

void

public

boolean graduated

Sets the graduated status of this Student.

roundCareerTime

void

public

double careerTimeNotRounded

Sets the careerTime of this Student. Round the given value to the nearest semester (Ex: 0.5, 1, 1.5, etc.) as specified in the fields section above.

Note: Only calculate the rounded time after all the levels have been entered.

toString format:

— Now displaying information about the student —

Name:

University:

Hard Topics Mastered:

Projects Completed:

Graduated:

Career Time: years

Level.java

This class represents each level (course) required to graduate.

Note: In the event that a student repeats a level, only the data from their most recent attempt should be saved.

Fields

Field Name

Type

Access Modifier

Description

levelNumber

int

private

Indicates the level number of this level. Using the default settings, this could be a value between 1 and 12, inclusive.

description

String

private

Describes the material the course covers based on the level number:

1 - Object-Oriented Programming and Problem Solving
2 - Programming in C
3 - Computer Architecture
4 - Data Structures & Algorithms
5 - Systems Programming
6 - Software Engineering I
7 - Compilers
8 - Operating Systems
9 - Introduction to Analysis and Algorithms
10 - Data Mining and Machine Learning
11 - Software Testing
12 - Software Engineering II
12+ - Diabolical Software Engineering Course
Note: 12+ refers to any level numbers of 13 or greater.

difficulty

String

private

The difficulty of the level will be determined based on the level number:

If the level number is less than or equal to 4, the difficulty is Easy.
If the level number is between 5 and 8, the difficulty is Intermediate.
If the level number is between 9 and 12, the difficulty is Hard.
If the level number is greater than 12, the difficulty is Diabolical.
acedTests

int

private

Number of exams in which the student receives a perfect score. Each aced exam gives a student one additional hard topic or one additional incomplete regular project without having to retake the course.

hardTopicsIncomplete

int

private

The number of difficult topics that the student does not complete.

regularProjectsIncomplete

int

private

The number of regular projects that the student does not complete.

capstoneProjectsIncomplete

int

private

The number of capstone projects a student does not complete.

time

double

private

The time spent on this course in years.

Note that a course will typically be 0.5 or 1.0 years in duration, but this variable will be less than that value because it will be proportional to the amount of time during the semester the student spends on this course (based on other courses student is taking and extracurricular involvements).

passed

boolean

private

The level is passed if the student has less than the maximum number of strikes allowed. Recall that typically, 2 strikes are allowed but this number can increase by 1 for every aced exam.

An incomplete capstone project is automatic failure of the course regardless how many strikes the student has and is allowed.

Constructor:

Access Modifier

Constructor Name

Input Parameters

Description

public

Level

int levelNumber,

int acedTests,

int hardTopicsIncomplete,

int regularProjectsIncomplete,

int capstoneProjectsIncomplete,

double time

Construct a newly allocated Level object and instantiate the fields to the specified parameters.

Set the description field using the options listed in the field description.

Set the difficulty field using the options listed in the field description.

Set the passed fields to false if the student fails a capstone project or if the sum of hard topics and incomplete projects is greater than 2. Otherwise, set passed to true.

Methods:

Method Name

Return Type

Access Modifier

Input Parameters

Description

toString

String

public

Return information about the level in the format provided in the next section.

This will be used to give the user information about the level if it is failed.

getPassed

boolean

public

Returns the passed status of this Level.

getLevelNumber

int

public

Returns the levelNumber of this Level.

getDescription

String

public

Returns the description of this Level.

getDifficulty

String

public

Returns the difficulty of this Level.

getAcedTests

int

public

Returns the acedTests of this Level.

getHardTopicsIncomplete

int

public

Returns the hardTopicsIncomplete of this Level.

getRegularProjectsIncomplete

int

public

Returns the regularProjectsIncomplete of this Level.

getCapstoneProjectsIncomplete

int

public

Returns the capstoneProjectsIncomplete of this Level.

getTime

double

public

Returns the time of this Level.

toString format:

Level Number:

Description:

Difficulty:

PlayGame.java

PlayGame will include all the logic used to actually play the game. This class must have a main method, though you are allowed to add additional methods if you like. Output samples are provided in the next section. Match the output exactly. The Starter Code includes all of the prompts you will need.

During gameplay, users will be prompted to enter their information and customization options. After that data is used to configure the game, they will be prompted to enter the data for each level until they quit or graduate.

For each level, players will enter the number of aced tests, topics not understood, regular projects incomplete, capstone projects incomplete, and time taken.

Note: You must create each of the classes and implement them as described in their respective sections. Failure to do so will negatively impact your score.

Sample Output

Sample Output 1

Welcome to Students of CS! Good luck with your college career!
Enter your name:
[John]
Enter your university:
[Purdue University]
Would you like to customize the number of levels?
[no]
Would you like to customize the number of hard topics per level?
[no]
Would you like to customize the number of projects per level?
[no]
Enter the number of aced tests in level 1:
[1]
Enter the number of topics not understood in level 1:
[0]
Enter the number of regular projects incomplete in level 1:
[0]
Enter the number of capstone projects incomplete in level 1:
[0]
Enter the time taken in level 1:
[0.3]
Enter the number of aced tests in level 2:
[2]
Enter the number of topics not understood in level 2:
[3]
Enter the number of regular projects incomplete in level 2:
[0]
Enter the number of capstone projects incomplete in level 2:
[0]
Enter the time taken in level 2:
[0.4]
Enter the number of aced tests in level 3:
[3]
Enter the number of topics not understood in level 3:
[1]
Enter the number of regular projects incomplete in level 3:
[0]
Enter the number of capstone projects incomplete in level 3:
[1]
Enter the time taken in level 3:
[0.2]
General information about the failed level is as follows:
Level Number: 3
Description: Computer Architecture
Difficulty: Easy
Would you like to play level 3 again?
[no]
— Now displaying information about the student —
Name: John
University: Purdue University
Hard Topics Mastered: 8
Projects Completed: 14
Graduated: false
Career Time: 1.0 years
Thank you for playing Students of CS!
Sample Output 2

Welcome to Students of CS! Good luck with your college career!
Enter your name:
[Sarah]
Enter your university:
[University of Iowa]
Would you like to customize the number of levels?
[yes]
Enter the number of levels to add or remove(use negative value to remove):
[1]
Would you like to customize the number of hard topics per level?
[no]
Would you like to customize the number of projects per level?
[no]
Enter the number of aced tests in level 1:
[0]
Enter the number of topics not understood in level 1:
[2]
Enter the number of regular projects incomplete in level 1:
[0]
Enter the number of capstone projects incomplete in level 1:
[0]
Enter the time taken in level 1:
[0.4]
Enter the number of aced tests in level 2:
[0]
Enter the number of topics not understood in level 2:
[0]
Enter the number of regular projects incomplete in level 2:
[1]
Enter the number of capstone projects incomplete in level 2:
[0]
Enter the time taken in level 2:
[0.2]
Enter the number of aced tests in level 3:
[4]
Enter the number of topics not understood in level 3:
[0]
Enter the number of regular projects incomplete in level 3:
[4]
Enter the number of capstone projects incomplete in level 3:
[0]
Enter the time taken in level 3:
[0.3]
Enter the number of aced tests in level 4:
[0]
Enter the number of topics not understood in level 4:
[0]
Enter the number of regular projects incomplete in level 4:
[0]
Enter the number of capstone projects incomplete in level 4:
[0]
Enter the time taken in level 4:
[0.1]
Enter the number of aced tests in level 5:
[1]
Enter the number of topics not understood in level 5:
[1]
Enter the number of regular projects incomplete in level 5:
[1]
Enter the number of capstone projects incomplete in level 5:
[0]
Enter the time taken in level 5:
[0.3]
Enter the number of aced tests in level 6:
[1]
Enter the number of topics not understood in level 6:
[0]
Enter the number of regular projects incomplete in level 6:
[2]
Enter the number of capstone projects incomplete in level 6:
[0]
Enter the time taken in level 6:
[0.2]
Enter the number of aced tests in level 7:
[0]
Enter the number of topics not understood in level 7:
[0]
Enter the number of regular projects incomplete in level 7:
[0]
Enter the number of capstone projects incomplete in level 7:
[0]
Enter the time taken in level 7:
[0.4]
Enter the number of aced tests in level 8:
[0]
Enter the number of topics not understood in level 8:
[2]
Enter the number of regular projects incomplete in level 8:
[0]
Enter the number of capstone projects incomplete in level 8:
[0]
Enter the time taken in level 8:
[0.1]
Enter the number of aced tests in level 9:
[4]
Enter the number of topics not understood in level 9:
[0]
Enter the number of regular projects incomplete in level 9:
[3]
Enter the number of capstone projects incomplete in level 9:
[0]
Enter the time taken in level 9:
[0.3]
Enter the number of aced tests in level 10:
[0]
Enter the number of topics not understood in level 10:
[0]
Enter the number of regular projects incomplete in level 10:
[2]
Enter the number of capstone projects incomplete in level 10:
[0]
Enter the time taken in level 10:
[0.2]
Enter the number of aced tests in level 11:
[0]
Enter the number of topics not understood in level 11:
[2]
Enter the number of regular projects incomplete in level 11:
[1]
Enter the number of capstone projects incomplete in level 11:
[0]
Enter the time taken in level 11:
[0.4]
General information about the failed level is as follows:
Level Number: 11
Description: Software Testing
Difficulty: Hard
Would you like to play level 11 again?
[yes]
Enter the number of aced tests in level 11:
[2]
Enter the number of topics not understood in level 11:
[0]
Enter the number of regular projects not completed in level 11:
[0]
Enter the number of capstone projects not completed in level 11:
[0]
Enter the time taken in level 11:
[0.3]
Enter the number of aced tests in level 12:
[2]
Enter the number of topics not understood in level 12:
[0]
Enter the number of regular projects not completed in level 12:
[0]
Enter the number of capstone projects not completed in level 12:
[0]
Enter the time taken in level 12:
[0.1]
Enter the number of aced tests in level 13:
[0]
Enter the number of topics not understood in level 13:
[2]
Enter the number of regular projects not completed in level 13:
[0]
Enter the number of capstone projects not completed in level 13:
[0]
Enter the time taken in level 13:
[0.4]
Congratulations Sarah, you have graduated!
Course Obstacles:
Levels: 13
Hard Topics Per Level: 4
Projects Per Level: 5
— Now displaying information about the student —
Name: Sarah
University: University of Iowa
Hard Topics Mastered: 45
Projects Completed: 52
Graduated: true
Career Time: 4.0 years
Thank you for playing Students of CS!
Note: Brackets [] are used to indicate input.

Additional Notes:

The starter code provided for PlayGame.java provides String constants that can be used for the prompts and the level descriptions. For the congratulations message, be sure to add in the name of the student.

The Yes/No inputs should be case-insensitive.

As shown in the examples, the congratulations statement and the career obstacles should only be printed if the student graduates.

Career time should always be printed with one decimal place.

If a student retries a level, only consider their most recent attempts when counting the projects completed and hard topics mastered.

You may assume the user inputs will be valid and logically correct.

Testing

We have included a program that will allow you to create and run output tests automatically in the Starter Code. This will make it easier for you to verify that each possible progression through your solution is correct. Take a look at RunLocalTest.java. There are many utility features and tools that you do not need to worry about at the moment, instead, focus on the test case. It is included in the Starter Code. Read through it.

You can modify the test to test any method you like by following the same format. You can either download the program and run the main method or use the “Run” button on Vocareum to run the test. You can repeat this process for each path.

Public Test Cases Note

For many homeworks and projects, we will give you test cases that correspond to several of the ways we will be testing your program. But, we will not give you test cases for ALL of the ways we will be testing your program. You should think of other test cases to use that will fully test every aspect of every feature of your program. Just because your program passes all the test cases we give you does not mean that it is fully correct and will receive a score of 100.

Submit

After testing your solution and verifying that it meets the requirements described in this document, you can submit on Vocareum. You have 10 submission attempts to achieve full points.

上一篇:git 错误 fatal: Not a valid object name: 'master'


下一篇:慕课网-安卓工程师初养成-6-3 如何使用 Java 中的数组