Skip to content

Commit

Permalink
[v0] add General class
Browse files Browse the repository at this point in the history
  • Loading branch information
yudong80 committed Aug 16, 2021
1 parent b9b667c commit a83173d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
4 changes: 4 additions & 0 deletions V0/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin"
}
18 changes: 18 additions & 0 deletions V0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

## Folder Structure

The workspace contains two folders by default, where:

- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the `bin` folder by default.

> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management

The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
23 changes: 23 additions & 0 deletions V0/src/coding/samguk/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package coding.samguk;

import java.util.Arrays;
import java.util.List;

public class App {
public void testCreateSomeGenerals() {
General 조홍 = new General("조홍", (218-50-1), 74, 47, 75, 41, 74, 72);
General 제갈량 = new General("제갈량", 181, 61, 100, 95, 92, 92, 78);

List<General> generals = Arrays.asList(조홍, 제갈량);
System.out.println(generals);
}


public static void main(String[] args) throws Exception {
System.out.println("Hello, Coding Samguk V0!");
App app = new App();

//1. 몇 명의 장수 만들어 보기
app.testCreateSomeGenerals();
}
}
39 changes: 39 additions & 0 deletions V0/src/coding/samguk/General.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package coding.samguk;

public class General {
private String name;

private int year; //태어난 해
private int warAbility; //무력
private int intelligence; //지력
private int charisma; //매력
private int politics; //정치력
private int armyCommand; //육전지휘
private int navalCommand; //수전지휘

private int army; //병사수
private int armyType; //병종

public General(String n,
int y, int w, int i, int c, int p,
int ac, int nc) {
name = n;
year = y;
warAbility = w;
intelligence = i;
charisma = c;
politics = p;
armyCommand = ac;
navalCommand = nc;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(name).append(",").append(year).append("::")
.append(warAbility).append(",").append(intelligence).append(",")
.append(charisma).append(",").append(politics).append("::")
.append(armyCommand).append(",").append(navalCommand);
return sb.toString();
}
}

0 comments on commit a83173d

Please sign in to comment.