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 }

  • 相关阅读:
    memcache详解
    redis详解
    laravel5表单验证
    MySQL添加字段和修改字段
    delete和truncate区别
    IOC 和DI(转载)
    JPA和SpringData知识梳理
    spring和springmvc配置分离
    springboot 整合 mybatis
    mongodb安装及配置
  • 原文地址:https://www.cnblogs.com/halflife/p/2078873.html
Copyright © 2011-2022 走看看