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 }

  • 相关阅读:
    再谈树形dp
    洛谷 P3627 [APIO2009]抢掠计划
    树状数组
    树形dp 入门
    洛谷P2014 选课
    洛谷P2015 二叉苹果树
    9 vue.js 被观察数组的变异方法
    8 vue的v-model指令学习
    7vue-事件修饰符
    6.vue事件绑定-click
  • 原文地址:https://www.cnblogs.com/halflife/p/2078873.html
Copyright © 2011-2022 走看看