Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions tdd-oop-inheritance.CSharp.Main/Article.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,12 @@

namespace tdd_oop_inheritance.CSharp.Main
{
public class Article {
public string title;

bool onLoan = false;

public class Article : LibraryItem {

public Article(string title) {
this.title = title;
}

public bool isOnLoan() {
return onLoan;
}

public string checkIn() {
if (!this.isOnLoan()) {
return "item is not currently on loan";
}

this.onLoan = false;

return "item has been checked in";
}

public string checkOut() {
if (this.isOnLoan()) {
return "item is currently on loan";
}

this.onLoan = true;

return "item has been checked out";
}

}
}
38 changes: 6 additions & 32 deletions tdd-oop-inheritance.CSharp.Main/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,11 @@

namespace tdd_oop_inheritance.CSharp.Main
{
public class Book {
public string title;

bool onLoan = false;

public Book(string title) {
this.title = title;
}

public bool isOnLoan() {
return onLoan;
}

public string checkIn() {
if (!this.isOnLoan()) {
return "item is not currently on loan";
}

this.onLoan = false;

return "item has been checked in";
}

public string checkOut() {
if (this.isOnLoan()) {
return "item is currently on loan";
}

this.onLoan = true;

return "item has been checked out";
}
public class Book : LibraryItem
{
public Book(string name)
{
this.title = name;
}
}
}
46 changes: 46 additions & 0 deletions tdd-oop-inheritance.CSharp.Main/LibraryItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tdd_oop_inheritance.CSharp.Main
{
public abstract class LibraryItem
{
public string title;

bool onLoan = false;



public bool isOnLoan()
{
return onLoan;
}

public virtual string checkIn()
{
if (!this.isOnLoan())
{
return "item is not currently on loan";
}

this.onLoan = false;

return "item has been checked in";
}

public virtual string checkOut()
{
if (this.isOnLoan())
{
return "item is currently on loan";
}

this.onLoan = true;

return "item has been checked out";
}
}
}
18 changes: 8 additions & 10 deletions tdd-oop-inheritance.CSharp.Main/Newspaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@

namespace tdd_oop_inheritance.CSharp.Main
{
public class Newspaper
public class Newspaper : LibraryItem
{
public string title;

Boolean onLoan = false;


public Newspaper(string title) {
this.title = title;
}

public bool isOnLoan() {
return onLoan;
}



public string checkIn() {

public override string checkIn() {
return "newspapers are not available for loan";
}

public string checkOut() {

public override string checkOut() {
return "newspapers are not available for loan";
}
}
Expand Down