用于以MLA样式打印段落的程序 [英] A program for printing a paragraph in MLA style

查看:81
本文介绍了用于以MLA样式打印段落的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一项任务,我需要一些帮助。这是作业

//

研究报告通常需要符合给定的标准,如APA或MLA。这些标准指定了边距的大小和标题,段落,参考,页码等格式。假设程序要生成符合标准的报告。期望提供实用程序类以自动符合这些标准。这样,应用程序只需要关注提供内容。实用程序类将提供诸如printParagraph(String test),printTitle(String title),printReference(String author,String title,int year,String publisher),printLine(String)和breakPage()等方法。


开发实用程序类以提供上面列出的方法。为类定义一个构造函数,该构造函数包含页面中的列数,页面中的行数和作者的名称。该课程将执行以下格式化:


左侧和右侧边距为1-5个空格

2-第一页后每页的第一行打印左对齐作者姓名和页码。

3-第二行和第三行(在顶部),每页的最后5行是空白的。第一页的第一行也是空白的。

4-打印标题是将标题置于页面中心。请注意,磁贴可能包含嵌入的新行字符,如果是中心并打印每一行。一个空白行是跟随标题。

5- printParagraph是执行自动换行。该段的第一行是缩进5个空格。

6- printReference用于格式化参考段落。那段是每个项目之间都有一个逗号,如果需要,在第一个上面的行上悬挂5个空格的缩进,执行自动换行。参考后打印一个空行。

7- breakPage()方法将打印足够的空行以完成当前页面。


有你的printLine如果传递的String超过可用的列数(即页面中的列数减去边距),则抛出RuntimeException。

包含获取实例变量的getter方法(例如,包含一个getAuthor(),以便类可以printTitle(getAuthor())将作者添加为标题。


编写一个测试程序来彻底测试你的课程。


奖励3分:允许指定额外的左右边距。因此,如果用户想要格式化左右两侧有额外缩进的段落,他们的程序可以调用方法在打印段落之前设置缩进,然后将额外的边距重置为0.如果你执行此任务,请确保你有一个测试用例,证明它是正常工作的ctly。


这是我所做的课程:

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | 换行 | 行号

解决方案

请原谅我,但我在这里闻到了一点TeX和LaTeX ......


亲切的问候,


Jos



请原谅我,但我在这里闻到了一点TeX和LaTeX ......


亲切的问候,


Jos



这些是法律或类别吗? API doc?


这些方法或类是否在API文档中?



不,TeX和LaTeX都不是Java的一部分。根据Wikipedia LaTeX是TeX排版程序的文档标记语言和文档准备系统(这是一个非常好的描述)。 LaTeX经常被用于科学工作(自然科学中的书籍是用LaTeX编写的),最初设计的是TeX,使得文本易于创作,而作者不必考虑布局(LaTeX是Leslie的扩展) La mport)。


有关更多信息,请查看 Wikipedia


某些地方可能有适用于Java的LaTeX库,但我认为JosAH的意思是,你应该这么做第二次发明轮子。


问候,

Nepomuk


Hi all,

I have an assignment and I need some help with it. This is the assignment
//
Research reports are often required to conform to a given standard such as APA or MLA. These standards specify things like the size of the margins and formats for titles, paragraphs, references, page numbers, etc. Suppose that a program is to produce a report conforming to a standard. It would be desirable to provide utility class to automatically conform to these standards. That way the application need only be concerned about supplying the content. The utility class would provide methods such as printParagraph(String test), printTitle(String title), printReference(String author, String title, int year, String publisher), printLine(String) and breakPage().

Develop a utility class to provide the above listed methods. Define a constructor for the class that takes number of columns in a page, number of lines in a page, and the author?s name. The class is to perform the following formatting:

1- 5 spaces for left and right margin
2- first line of every page after the first page is to print left justified the authors name and page number.
3- the second and third lines (at the top), and the last 5 lines of each page are to be blank. The first line of the first page is also blank.
4- the print title is to center the title across the page. Note the tile may contain embedded new line characters, if so center and print each line. A blank line is to follow the title.
5- the printParagraph is to perform word wrap. The first line of the paragraph is to be indented 5 spaces.
6- the printReference is to format a reference paragraph. That is the paragraph is to have a comma between each item, perform word wrap if needed with a hanging indent of 5 spaces on lines past the first. A blank line is printed after a reference.
7- the breakPage() method will print enough blank lines to complete the current page.

Have your printLine method throw a RuntimeException in the event that the String passed exceeds the available number of columns (i.e. number of columns in a page less the margins.

Include getter methods to get the instance variables (e.g. include a getAuthor() so that the class can to printTitle(getAuthor()) to add the author centered as a title.

Write a test program to thoroughly test your class.

Bonus 3 points: Allow and additional left and right margin to be specified. Thus if a user wanted to format a paragraph that had an extra indent on both the left and right, their program could call the methods to set the indent before print paragraph then reset the extra margin to 0 afterwards. If you do this task make sure you have a test case that demonstrates it is working correctly.

This is the class that I did:

Expand|Select|Wrap|Line Numbers

解决方案

Pardon me for saying so but I smell a bit of TeX and LaTeX here ...

kind regards,

Jos


Pardon me for saying so but I smell a bit of TeX and LaTeX here ...

kind regards,

Jos

Are these methouds or classes and are they in the API doc?


Are these methouds or classes and are they in the API doc?

No, TeX and LaTeX aren''t Part of Java. According to Wikipedia LaTeX is a document markup language and document preparation system for the TeX typesetting program (which is a pretty good description). LaTeX is often used in scientific work (loads of Books in natural sciences are written with LaTeX) as TeX was originally designed, to make texts easy to create without the author having to think about the layout (and LaTeX is an extension to that by Leslie Lamport).

For more information, check Wikipedia.

There might be LaTeX libraries for Java available somewhere, but I think what JosAH meant was, that you''re supposed to invent the wheel a second time.

Greetings,
Nepomuk


这篇关于用于以MLA样式打印段落的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆