zoukankan      html  css  js  c++  java
  • 【笔记】Eclipse and Java for Total Beginners—010

    Lesson10 – Start on MyLibrary Class

    • Create MyLibrary Test JUnit test
    • Create testMyLibrary to test MyLibrary constructor
    • Create MyLibrary constructor
    • Introduce instanceof operator
    • Introduce assertTrue method

    1 package org.totalbeginner.tutorial;
    2
    3  import java.util.ArrayList;
    4
    5  import junit.framework.TestCase;
    6
    7  public class MyLibraryTest extends TestCase {
    8 public void testMyLibrary() {
    9 MyLibrary ml = new MyLibrary("Test");
    10
    11 assertEquals("Test", ml.name);
    12
    13 assertTrue(ml.books instanceof ArrayList);
    14 assertTrue(ml.people instanceof ArrayList);
    15
    16
    17 }
    18
    19 }

    1 package org.totalbeginner.tutorial;
    2
    3 import java.util.ArrayList;
    4
    5 import org.totoalbeginner.tutorial.Person;
    6
    7 public class MyLibrary {
    8
    9 String name;
    10 ArrayList<Person> people;
    11 ArrayList<Book> books;
    12
    13 public MyLibrary(String name) {
    14 this.name = name;
    15 books = new ArrayList<Book>();
    16 people = new ArrayList<Person>();
    17
    18 }
    19
    20 }

  • 相关阅读:
    [SDOI2015]星际战争
    [SDOI2016]生成魔咒
    hdu3311
    [ZJOI2011]最小割
    P3331 [ZJOI2011]礼物(GIFT)
    [ZJOI2010]贪吃的老鼠
    状压dp-----三进制
    noip2016 天天爱跑步
    概率期望dp
    poj2186
  • 原文地址:https://www.cnblogs.com/halflife/p/2078873.html
Copyright © 2011-2022 走看看